Skip to content
English

How it works

The text in the field is the query. Matching tries a plain substring first, then letters in order ("nyk" finds New York), and ranks contiguous runs higher. On close the field returns to the chosen label, so a half-typed query never stands in for a value. The panel is not portaled, so it stays put inside dialogs and scroll areas.

Use it for

  • Choosing one value from a long list people know by name: a city, a person, a project.
  • When typing is faster than scrolling, on desktop and mobile alike.

Look elsewhere when

  • Under eight options: use a select or radio group.
  • Several values: use a multi-select or tags input.
  • Running commands: use a command palette.

Usage

import { useState } from 'react'
import { Combobox } from './Combobox.jsx'

const cities = [
  { value: 'lis', label: 'Lisbon', description: 'UTC+0' },
  { value: 'sgp', label: 'Singapore', description: 'UTC+8' },
  { value: 'tyo', label: 'Tokyo', description: 'UTC+9' },
]

export function ZoneField() {
  const [zone, setZone] = useState(null)
  return (
    <>
      <label htmlFor="zone">Time zone</label>
      <Combobox id="zone" options={cities} value={zone} onChange={setZone} placeholder="Search a city" />
    </>
  )
}

Props

PropTypeDefaultWhat it does
options{ value, label, description?, disabled? }[]—The options; value must be unique. label is what is matched and shown in the field.
valuestring | number | null—Controlled value; null means nothing chosen.
defaultValuestring | number | nullnullInitial value when uncontrolled.
onChange(value, option) => void—Called when an option is chosen, or with nulls when Esc clears a closed field.
placeholderstring'Search'Hint in the empty field.
renderOption(option) => ReactNode—Leading content for each row, such as an avatar or badge.
emptyTextstring—Text when nothing matches; defaults to labels.noMatch.
disabledbooleanfalseDisables the field.
invalidbooleanfalseDanger outline and aria-invalid.
labelsobject—Replaces built-in text: noMatch, results(n), toggle.
...restHTMLAttributes<HTMLDivElement>—Go to the root; id and aria-label / labelledby / describedby go to the input. List height: --ds-combo-list-height (248px); layer: --ds-combo-z (30).

Accessibility

  • Follows the ARIA 1.2 combobox pattern with list autocomplete: the input has role="combobox", aria-expanded, aria-controls and aria-activedescendant; the list is a listbox with aria-selected options.
  • Keyboard: Down / Up open and move (skipping disabled rows), Alt+Up closes, Home / End jump when not searching, Enter chooses, Esc closes or, when closed, clears, Tab closes.
  • The number of results is announced in a polite live region while searching.
  • Matches are shown by weight and a tint, not colour alone. Rows are 40px, 44px on touch. Reduced motion removes the panel and check animations.

Motion

The panel enters in 220ms ease-out from 6px above and scale 0.96. The field turns white with a halo over 220ms; the chevron turns in 240ms. The check on the chosen row pops with a 320ms spring.

Add it to your project

Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.

Combobox.jsxcombobox.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Form inputs
Availability grid comes with Pro. Its preview shows once you unlock it.
Boolean operations comes with Pro. Its preview shows once you unlock it.
Cascader comes with Pro. Its preview shows once you unlock it.