Installation
$ pnpm dlx shadcn@latest add @synccn/selectFirst time in this project? Connect synccn with one command.
Usage
import { Select } from "@/components/ui/select";<Select options={frameworks} placeholder="Pick one" />API reference
Generated from the component's TypeScript types, so it always matches the code.
Select
Accessible listbox select with keyboard navigation and typeahead. options: [{ value, label, icon?, disabled?, group? }]
PropTypeDescription
- optionsrequired
SelectOption[]Choices.
- value
stringControlled value.
- defaultValue
stringInitial value when uncontrolled.
- onValueChange
(value: string) => voidCalled with the new value.
- placeholder
stringDefault
"Select an option"Shown when nothing is selected.
- disabled
booleanPrevents opening.
- aria-label
stringAccessible name if there's no visible label.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Helpers
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for Check, ChevronsUpDown
Keyboard
- EnterorSpaceor↓Open the list
- ↓or↑Move between options, skipping disabled ones
- EnterChoose the highlighted option
- EscorTabClose the list
Accessibility
- The trigger has role combobox with aria-expanded and aria-controls; options use listbox and option roles.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: combobox, listbox, option, presentation
- ARIA attributes: aria-controls, aria-disabled, aria-expanded, aria-label, aria-selected
- Keys handled: ArrowUp, ArrowDown, Enter, Tab, Space
- Closes with Escape
- Closes when you click or tap outside
- Flips to whichever side has room, so it stays on screen
- Shows a visible focus ring for keyboard users
More inputs
ButtonSeven variants, four sizes and a built-in loading state.InputText field with optional leading icon and invalid state.TextareaMulti-line field that grows with its content and counts characters.CheckboxChecked, unchecked and indeterminate, with label and description.SwitchToggle with a springy thumb in three sizes.Radio GroupPick one option, shown as dots or as selectable cards.