Dashral Pro is on the wayGet 30% off at launch

Dashral

Combobox

A searchable select — type to filter a long list of options.

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

Selected value: bandung

Installation

$ pnpm dlx shadcn@latest add https://dashral.com/r/combobox.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/combobox

Usage

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

Assignee

Avatars in the list and the field; the email is searched too. Picking the same person again unassigns.

ENG-1042

Redesign the checkout flow

Country with flags

icon and description on each option; the pick sets the phone field's dialing code.

+62

API reference

Combobox

PropTypeDefault
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 / defaultValuestring

Picked value, controlled or initial. Picking it again clears it.

""
onValueChange(value: string) => void

Called with the new value.

—
placeholder / searchPlaceholder / emptyTextstring

Texts for the button, the search field and no results.

—
id / disabled / aria-label / className

Passed to the trigger button.

—
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.

—

Keyboard

KeysAction
EnterorSpaceor↓Open the list (on the button)
TypeFilter the list
↓or↑Move through the options
EnterPick the highlighted option
EscapeClose

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.