A custom dropdown for choosing one option from a list.
$ pnpm dlx shadcn@latest add https://dashral.com/r/select.jsonInstallation
$ pnpm dlx shadcn@latest add https://dashral.com/r/select.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/selectUsage
import { Select } from "@/components/dashral/select"
<Select
label="Status"
placeholder="Pick a status"
options={[
{ value: "active", label: "Active" },
{ value: "paused", label: "Paused" },
{ value: "archived", label: "Archived" },
]}
/>Examples
API reference
Select
Also takes every prop of Radix Select(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
value / defaultValue | string | — |
onValueChange | (value: string) => voidCalled with the new value. | — |
options | (string | { value; label?; description?; icon?; disabled? } | { label?; options })[]The choices, or groups of them (a line between groups). Required. | — |
placeholder | ReactNodeShown while nothing is picked. | — |
prefix | ReactNodeInside the trigger before the value, e.g. an icon. | — |
size | "default" | "sm"The trigger's height. | "default" |
side | "top" | "bottom"Which side the list opens on. | "bottom" |
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. | — |
className | stringThe trigger's classes. | — |
Keyboard
| Keys | Action |
|---|---|
| EnterorSpaceor↓ | Open |
| ↓or↑orLetters | Move |
| Enter | Pick |
| Escape | Close |
Accessibility
- A combobox button and a listbox, both labelled. Use NativeSelect for very long lists on phones.
- With label, description or error, the id, aria-describedby and aria-invalid are wired up for you.
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.