Combobox

Forms
Selection

Searchable select component with keyboard navigation, option descriptions, and optional create functionality. Ideal for selecting from large option lists.

Preview

Searchable select with options and descriptions

Creatable

Allow creating new options on the fly

Total options: 3

Loading State

Show loading indicator while fetching options

Disabled State

Disabled with and without value

Props

Combobox component API reference

PropTypeDefaultDescription
optionsComboboxOption[][]Array of options to display
valuestringSelected option value
onChange(value: string | null) => voidCallback when selection changes
labelstringLabel text above input
placeholderstring'Search...'Placeholder text
emptyTextstring'No results found'Text when no options match
clearablebooleantrueAllow clearing selection
creatablebooleanfalseAllow creating new options
onCreate(option: ComboboxOption) => voidCallback when creating new option
loadingbooleanfalseShow loading indicator
disabledbooleanfalseDisable the combobox

ComboboxOption Type

PropTypeDefaultDescription
value*stringOption value
label*stringDisplay label
descriptionstringOptional description text

Usage

Import and implementation example

import { Combobox, ComboboxOption } from '@/components/ui/combobox'

const options: ComboboxOption[] = [
  { value: 'react', label: 'React', description: 'A JavaScript library' },
  { value: 'vue', label: 'Vue.js', description: 'Progressive framework' },
  { value: 'angular', label: 'Angular', description: 'Platform for apps' },
]

export default function Example() {
  const [value, setValue] = useState<string | null>(null)
  const [options, setOptions] = useState(initialOptions)

  return (
    <>
      {/* Basic usage */}
      <Combobox
        label="Framework"
        options={options}
        value={value}
        onChange={setValue}
        placeholder="Search frameworks..."
      />

      {/* Creatable */}
      <Combobox
        label="Tags"
        options={options}
        value={value}
        onChange={setValue}
        creatable
        onCreate={(opt) => setOptions([...options, opt])}
      />
    </>
  )
}

Features

Built-in functionality

  • Real-time search: Filter options as you type
  • Keyboard navigation: Arrow keys, Enter, and Escape support
  • Option descriptions: Secondary text for additional context
  • Create new options: Add options that dont exist
  • Clear selection: One-click to clear current selection
  • Loading state: Spinner while fetching options
  • ARIA compliant: Full combobox ARIA pattern implementation
  • Dark mode: Full dark mode support

Accessibility

Accessibility considerations

ARIA Attributes

role="combobox" on inputrole="listbox" on options containerrole="option" on each optionaria-expanded indicates dropdown statearia-activedescendant tracks highlighted option

Keyboard Navigation

KeyAction
Arrow DownOpen dropdown / Move to next option
Arrow UpMove to previous option
EnterSelect highlighted option
EscapeClose dropdown

Notes

  • Options highlighted on hover and keyboard focus
  • Selected option shows checkmark indicator
  • Empty state announced to screen readers
  • Create option available via keyboard