Dashral Pro is on the wayGet 30% off at launch

Dashral

Select

A custom dropdown for choosing one option from a list.

$ pnpm dlx shadcn@latest add https://dashral.com/r/select.json

Installation

$ pnpm dlx shadcn@latest add https://dashral.com/r/select.json

Adds 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:

components.json
{
  "registries": {
    "@dashral": "https://dashral.com/r/{name}.json"
  }
}

Then add components by name:

$ pnpm dlx shadcn@latest add @dashral/select

Usage

example.tsx
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

Groups and an error

Groups are { label, options }; a separator goes between them.

Pick the timezone your reports should use.

Icons and descriptions

An option can carry an icon and a description; only its label shows in the trigger.

Who gets the follow-up.

API reference

Select

Also takes every prop of Radix Select(opens in a new tab).

PropTypeDefault
value / defaultValuestring—
onValueChange(value: string) => void

Called with the new value.

—
options(string | { value; label?; description?; icon?; disabled? } | { label?; options })[]

The choices, or groups of them (a line between groups). Required.

—
placeholderReactNode

Shown while nothing is picked.

—
prefixReactNode

Inside 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"
labelReactNode

Shown above, linked to the control.

—
descriptionReactNode

A hint under the control.

—
errorboolean | ReactNode

true shows the error style; a message also shows under the control.

—
labelActionReactNode

At the end of the label's row, e.g. a “Forgot password?” link or the current value.

—
withAsteriskboolean

Marks the label with an asterisk, e.g. alongside required.

false
classNames{ root, label, description, error, trigger, content, item }

Classes for each part.

—
classNamestring

The trigger's classes.

—

Keyboard

KeysAction
EnterorSpaceor↓Open
↓or↑orLettersMove
EnterPick
EscapeClose

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.