Components

Combobox

An animated React combobox — a searchable select and an autocomplete multi-select built on shadcn/ui's Popover + Command recipe (Radix and cmdk) with Motion: the panel eases open, results filter with layout animations and highlighted matches, and selections become removable animated chips.

  • shadcn Popover + Command
  • cmdk
  • Motion layout
  • Multi-select chips
  • Keyboard accessible

Installation

$ npx shadcn@latest add https://duskui.com/r/combobox.json

shadcn/ui has no Combobox primitive — it is a recipe composed from Popover and Command. DuskUI ships it as a ready-made component that installs the DuskUI Button and Popover with it. Filtering is done in the component (cmdk's shouldFilter is off) so results can animate.

Usage

framework-picker.tsx
"use client"

import * as React from "react"
import { Combobox } from "@/components/dusk/combobox/combobox"

const frameworks = [
  { value: "next", label: "Next.js" },
  { value: "remix", label: "Remix" },
  { value: "astro", label: "Astro" },
]

export function FrameworkPicker() {
  const [value, setValue] = React.useState("")
  return (
    <Combobox
      aria-label="Framework"
      options={frameworks}
      value={value}
      onValueChange={setValue}
      placeholder="Select a framework…"
    />
  )
}

Examples

Default

The panel scales out of the trigger and options cascade in. As you type, matches that start with the query move to the top and every option slides to its new place, the list height eases to fit, matched text is bolded and a highlight pill glides with the arrow keys. When nothing matches, an empty state fades in. The trigger crossfades to the new label.

Icons & descriptions

Options can carry an icon (shown in the trigger too), a description and extra search keywords — try “golang”. allowDeselect={false} keeps a value selected.

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Multi-select Combobox

Type right in the field to filter, pick as many as you like and each becomes a chip that scales in. Chips slide over to make room and shrink away when removed with their ✕ or Backspace. Options show checkboxes that draw themselves, max caps the selection with a counter, and every change is announced to screen readers.

Skills

ReactMotion

Pick up to 5. Backspace removes the last one.

$ npx shadcn@latest add https://duskui.com/r/multi-combobox.json
PropTypeDefaultDescription
options{ value, label, icon?, keywords?, disabled? }[]—The choices.
value / onValueChangestring[] / (value: string[]) => void—Controlled selection.
defaultValuestring[][]Uncontrolled initial selection.
maxnumber—Stop adding at this many; shows a counter and Clear button.
placeholderstring"Search…"Shown while nothing is selected.
emptyMessageReactNode"No results found."Shown when nothing matches.
namestring—Submits each value with its own hidden input.
aria-labelstring"Options"Names the input and list.
disabledbooleanfalseDisable the whole field.
className / contentClassNamestring—Classes for the field and the panel.

API Reference

Combobox props. Anything else (id, aria-label, className, disabled…) is forwarded to the trigger Button.

PropTypeDefaultDescription
options{ value, label, description?, icon?, keywords?, disabled? }[]—The choices. `label` is searched; `keywords` add extra matches.
value / onValueChangestring / (value: string) => void—Controlled selection; "" when cleared.
defaultValuestring""Uncontrolled initial selection.
placeholder / searchPlaceholderstring—Trigger text when empty, and the search input placeholder.
emptyMessageReactNode"No results found."Shown when nothing matches.
allowDeselectbooleantruePicking the selected option again clears it.
namestring—Submits the value with a hidden input.
contentClassNamestring—Classes for the panel. Other props go to the trigger Button.

Accessibility

  • The Combobox trigger is a button with role="combobox", aria-expanded and aria-haspopup="listbox"; name it with a <label htmlFor> or aria-label.
  • Inside, cmdk wires the search input (role="combobox", aria-activedescendant) to the listbox, so Up, Down, Home, End and Enter work without leaving the input.
  • Radix Popover returns focus to the trigger on close and closes on Escape or an outside click.
  • The multi-select keeps focus in its input, marks the list aria-multiselectable and options aria-checked, gives every chip a labelled remove button, and announces additions and removals in a polite live region.
  • Match highlighting uses <mark>; the gliding highlight pill is decorative (aria-hidden).
  • Under prefers-reduced-motion the panel and chips only fade, the list stops sliding and the highlight jumps.