Client component

Combobox

A filterable single-value picker on the ARIA combobox pattern.

Import#

import { Combobox } from "astralis-ui";

Type to filter, arrows to move, Enter to commit, Escape to revert to the last committed selection. Reopening on a committed value shows the full list. Filtering only kicks in once you type.

Compared to Select: Select is a button you pick from; Combobox is an input you search in. For multiple values, use MultiSelect. All three share the same option machinery, so options shapes are interchangeable.

Free-form values#

By default the options are a closed set: text that matches nothing reverts on blur. With allowCustomValue they become suggestions, and whatever the user typed commits as the value on Tab, on blur, or on Enter when no option is highlighted. Text that exactly matches an option's label commits that option, and Escape still reverts.

Props#

PropTypeDefaultDescription
optionsArray<{label, value, disabled?} | {group, options}>[]Flat or grouped options.
value / defaultValuestring | number | nullNoneControlled / uncontrolled selection; null means nothing is selected.
onChange(value) => voidNoneFires on commit (pick or clear).
onInputChange(text) => voidNoneFires on every filter keystroke.
placeholderstringNoneInput text shown while nothing is typed or selected.
allowCustomValuebooleanfalseTyped text that matches no option commits as the value, so the options become suggestions. Tab, blur, or Enter with nothing highlighted commits; Escape reverts.
clearablebooleanfalse✕ button when a value is selected.
emptyTextstring"No matches"Shown when nothing matches.
size"sm" | "md" | "lg""md"Field height and text size, matching Input.
variant"outline" | "filled" | "underline" | "unstyled""outline"Field chrome, matching Input.
colorSchemeall 15 schemes"brand"Hue for the focus ring and the highlighted option.
loadingbooleanfalseShows a spinner and disables the input while options load.
invalidbooleanfalseError styling and aria-invalid. Inherited inside a Field.
disabledbooleanfalseBlocks interaction. Inherited inside a Field.
readOnlybooleanfalseShows the value but can't be changed.
namestringNoneHidden input for native form submission.

Keyboard#

KeyAction
typeFilter the options
↓Open when closed; move the highlight down
↑Move the highlight up
EnterCommit the highlighted option
EscClose and revert to the last committed value
TabClose, revert, and move on

Accessibility#

role="combobox" with aria-autocomplete="list", aria-expanded, aria-controls and aria-activedescendant tracking the highlighted option: the screen reader follows the highlight while focus stays in the input. Label/description wiring comes from Field.