Installation
$ pnpm dlx shadcn@latest add @synccn/comboboxFirst time in this project? Connect synccn with one command.
Usage
import { Combobox } from "@/components/ui/combobox";<Combobox options={zones} />API reference
Generated from the component's TypeScript types, so it always matches the code.
Combobox
Searchable select. options: [{ value, label, hint? }]
PropTypeDescription
- optionsrequired
ComboboxOption[]Choices.
- value
stringControlled value.
- defaultValue
stringInitial value when uncontrolled.
- onValueChange
(value: string | undefined) => voidCalled with the new value (undefined when cleared).
- placeholder
stringDefault
"Select…"Shown when nothing is selected.
- searchPlaceholder
stringDefault
"Search…"Placeholder for the search field.
- empty
React.ReactNodeDefault
"No matches. Try a different word."Shown when the search matches nothing.
- 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, Search
Keyboard
- ↓or↑Move through matching options
- EnterChoose the highlighted option
- EscClose the list
Accessibility
- Typing filters the list; the input keeps focus while you move through options.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: combobox, listbox, option
- ARIA attributes: aria-expanded, aria-selected
- Keys handled: ArrowUp, ArrowDown, Enter
- 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.