A searchable select — type to filter a long list of options.
$ pnpm dlx shadcn@latest add https://dashral.com/r/combobox.jsonInstallation
$ pnpm dlx shadcn@latest add https://dashral.com/r/combobox.jsonAdds the component, the components it builds on, its npm packages and the theme tokens it uses. Using Dashral often? Add the registry to components.json once:
{
"registries": {
"@dashral": "https://dashral.com/r/{name}.json"
}
}Then add components by name:
$ pnpm dlx shadcn@latest add @dashral/comboboxUsage
import { Combobox } from "@/components/dashral/combobox"
<Combobox
label="Country"
placeholder="Pick a country"
options={[
{ value: "id", label: "Indonesia" },
{ value: "sa", label: "Saudi Arabia" },
{ value: "us", label: "United States" },
]}
/>Examples
API reference
Combobox
| Prop | Type | Default |
|---|---|---|
options | { value, label, icon?, description?, disabled? }[]What can be picked. Required. icon sits before the label (an avatar, a flag), also in the field once picked; description is a second line, searched too. | — |
value / defaultValue | stringPicked value, controlled or initial. Picking it again clears it. | "" |
onValueChange | (value: string) => voidCalled with the new value. | — |
placeholder / searchPlaceholder / emptyText | stringTexts for the button, the search field and no results. | — |
id / disabled / aria-label / className | Passed to the trigger button. | — |
label | ReactNodeShown above, linked to the control. | — |
description | ReactNodeA hint under the control. | — |
error | boolean | ReactNodetrue shows the error style; a message also shows under the control. | — |
labelAction | ReactNodeAt the end of the label's row, e.g. a “Forgot password?” link or the current value. | — |
withAsterisk | booleanMarks the label with an asterisk, e.g. alongside required. | false |
classNames | { root, label, description, error, trigger, content, item }Classes for each part. | — |
Keyboard
| Keys | Action |
|---|---|
| EnterorSpaceor↓ | Open the list (on the button) |
| Type | Filter the list |
| ↓or↑ | Move through the options |
| Enter | Pick the highlighted option |
| Escape | Close |
Accessibility
- The trigger is role="combobox" with aria-expanded; options are role="option" with the highlighted one marked.
Motion
- Opens with a fade, a scale from 95%, a 2px blur clearing and a 4px slide from its trigger's side, on the spring (--duration-standard); closes faster (--duration-fast, --ease-exit). No blur with reduced motion.