Combobox

Filterable text field with an option list, optional async loading, and custom values.

Also known as: autocomplete, typeahead, filter select

Installation

Install with the CLI, or copy the component source into your project.

Add combobox (npm)

npx --yes -p @default-file/ui df-ui add combobox

Default

Filterable field with static options. The list opens on focus.

Filtering

Type in the field to filter by label or value. Disabled options stay in the list but cannot be chosen.

Async loading

loadOptions fetches rows for the current query. Toggle loading to see the catalogue loading copy, then the resolved list. debounceMs is 0 in this preview.

Custom value

allowCustomValue commits text that is not in the list. Type a name and press Enter.

Empty

Custom empty copy when the option list has no rows.

External label

Visible Label wired with htmlFor, id, and aria-labelledby so the combobox input is named.

Disabled and invalid

Disabled field with a committed value. Invalid chrome on an empty field.

Properties

Filterable text field backed by Option List. Supports static options, async loading, clear, and optional custom values.

Combobox

PropTypeDefaultNotes
valuestring-Controlled committed option value. The input shows the matching label; typing uses a separate query string.
defaultValuestring-Uncontrolled initial option value.
onValueChange(value: string) => void-Called with the option value when a selection is committed, or with custom text when allowCustomValue is set.
optionsreadonly ComboboxOption[]-Static options to filter.
loadOptions(query: string) => Promise<ComboboxOption[]>-Async option loader for the current query.
allowCustomValueboolean-Allow committing text that is not in the option list.
clearablebooleantrueShow a clear control when the field has text.
placeholderstring-Input placeholder.
disabledboolean-Disable the field.
invalidboolean-Mark the field invalid for styling and aria-invalid.
openboolean-Controlled list open state.
defaultOpenboolean-Uncontrolled initial open state.
onOpenChange(open: boolean) => void-Called when the list open state changes.
debounceMsnumber-Debounce for async loadOptions.
idstring-Id on the text input.
emptyContentReactNode-Content when the filtered list is empty.
itemChromeListItemChromeProps-Default List Item chrome for every option row.
aria-labelstring-Accessible name when no aria-labelledby is set.
aria-labelledbystring-Id of an external label. When set, aria-label is omitted so the external name wins.
classNamestring-Additional styles on the root.