Skip to content
GitHub (opens in a new tab)

Combobox

Type to filter one value, including a list the parent loads asynchronously.

stableMoleculecontracts/combobox.json

Preview

Combobox

Type to filter one value. Arrow keys move through the list, Enter selects, and Escape closes. Pass onQueryChange when the list loads asynchronously.

Master

A fixed list filtered as you type. Async search is a variant.

Usage

Wrap with Field. Use Select for a short fixed menu. Use Combobox when the person types to search, including when options arrive later. Command is still the command palette.

Do's

  • A long list the person searches by typing
  • Options that arrive after a query (async)
  • One value, with keyboard navigation through the suggestions

Don'ts

<Field label="City" htmlFor="city"><Combobox id="city" options={cities} /></Field>

When to use

  • A long list the person searches by typing
  • Options that arrive after a query (async)
  • One value, with keyboard navigation through the suggestions

When not to use

  • A short fixed list in a field menu — use Select
  • Several values — use MultiSelect
  • Tags the person types — use TagInput
  • A command palette — use Command

What an agent reads

import { Combobox } from "agentic-ds-kit";
must
  • Escape closes only this panel, not a parent Modal, Drawer or AlertDialog
  • Input is role=combobox, aria-autocomplete=list, aria-expanded, aria-controls, aria-activedescendant
  • Suggestions are role=listbox and each row is role=option with aria-selected
  • Arrow keys, Home, and End move the active option. Enter selects it. Escape closes and returns focus to the input
  • The popup shows one state at a time: loading (kit Spinner), the start hint, no results, or the list
  • Must have a Field label or ariaLabel
  • Highlight: the fill is one decorative layer (aria-hidden) that glides to the active option on hover and arrow keys (clip-path only, --motion-expand-*); it lands in place on first show, after the pointer leaves and on resize or scroll, and jumps with no slide under prefers-reduced-motion. Roles, aria-selected, aria-activedescendant and focus order are unchanged and the focus ring stays on the row
defaults
  • size md
  • placeholder Search
  • disabled false
  • error false
  • loading false
  • loadingLabel Loading
  • emptyLabel No results
  • allowCustomValue false
stops if
  • Do not use a native select or datalist
  • Do not invent ComboboxInput, ComboboxList, or ComboboxItem
  • Do not use raw hex

From contracts/combobox.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
idstringYes——
sizemd | sm | lgNomdHeights 32 / 36 / 40, the shared Button and Input scale.
optionsarrayYes——
placeholderstringNoSearch—
disabledbooleanNofalse—
errorbooleanNofalse—
valuestringNo—Controlled. Empty string is nothing selected.
defaultValuestringNo——
onChangefunctionNo—(value: string) => void
onQueryChangefunctionNo—When set, options are not filtered locally. Parent replaces options as the query changes.
loadingbooleanNofalse—
loadingLabelstringNoLoadingShown with a kit Spinner while loading.
startLabelstringNo—Shown in place of the list until the person types, like Start typing to find a customer. For async search.
emptyLabelstringNoNo resultsShown when a query matches nothing.
allowCustomValuebooleanNofalseEnter commits the typed text when nothing is highlighted.
namestringNo——
ariaLabelstringNo——
describedBystringNo——
  • Component
    →

    Select

    Choose one or several options from a list.

  • Component
    →

    MultiSelect

    Choose several values.

  • Component
    →

    TagInput

    Tags the person types.

  • Component
    →

    Command

    Searchable command menu for quick actions.