Skip to content

Combobox

A searchable select with chips for multiple values, on Base UI Combobox.

With a label

With a clear button

With groups

Several values

Disabled

Invalid

Installation

npx shadcn@latest add @khaeli/combobox

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

npm packages
  • @base-ui/react ^1.7.0
  • @keyline-icons/react ^2.2.0

Keyboard

A to Z
Typing opens the list and narrows it. Nothing is highlighted until an arrow key is pressed.
ArrowDownArrowUp
Open the list and move the highlight. Focus stays in the input.
Enter
Chooses the highlighted option and closes the list. With nothing highlighted it closes the list and puts back the value there was.
Escape
Closes the list. Pressed again, clears the value.
Tab
Moves from the input to the button that opens the list, then on.
ArrowLeftArrowRight
With several values, move between the chips and the input.
Backspace
With several values, removes the focused chip, or the last chip when the input is empty.

Accessible name

  • The input has role="combobox". Give ComboboxInput (or ComboboxChipsInput) an id and point a @khaeli/label at it with htmlFor, or give it an aria-label.
  • The button that opens the list is named "Show options" and the clear button "Clear": change them with triggerLabel and clearLabel on ComboboxInput. A chip's remove button is named "Remove" and the chip's text; change it with removeLabel on ComboboxChip.
  • ComboboxLabel names a ComboboxGroup. ComboboxEmpty is a polite live region: it is read when nothing matches.
  • For an invalid combobox, put aria-invalid and aria-describedby on ComboboxInput.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/combobox.json