A styled native <select> — fully accessible and mobile-friendly.
$ pnpm dlx shadcn@latest add https://dashral.com/r/native-select.jsonInstallation
$ pnpm dlx shadcn@latest add https://dashral.com/r/native-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/native-selectUsage
import { NativeSelect } from "@/components/dashral/native-select"
<NativeSelect
label="Country"
placeholder="Pick a country"
options={[
{ value: "id", label: "Indonesia" },
{ value: "sa", label: "Saudi Arabia" },
{ value: "us", label: "United States" },
]}
/>Examples
Regional settings
Language, currency and a grouped time zone list, with a live preview of how an order is written.
API reference
NativeSelect
Also takes every prop of <select>(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
options | (string | { value; label?; disabled? } | { label; options })[]The choices, or groups of them (an <optgroup> each). Required. | — |
placeholder | stringShown while nothing is picked. | — |
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, select, icon }Classes for each part. | — |
className | stringExtra classes, merged with cn() so yours win. | — |
Keyboard
| Keys | Action |
|---|---|
| ↓or↑orLetters | The browser's own select keys |
Accessibility
- A real <select>: the most robust choice on phones and with assistive technology.
- With label, description or error, the id, aria-describedby and aria-invalid are wired up for you.