Duolith docs

Combobox

A text field that suggests options as the user types; choosing one fills the field.

Stability: experimental

Props

PropTypeDefaultMeans
labelstringThe label above the field, and its accessible name.
optionsstring[]Every option; those containing what was typed are suggested, six at most.
valuestringbindable("")The text. Bind it with bind:value={name}.
placeholderstringHint text while empty.
onChoose(option: string) => voidRuns when a suggestion is chosen.

States

StateLooks like
emptyThe field only.
suggestingA listbox of matching options under the field, on the overlay layer.

Accessibility

rolecombobox (the field), with aria-expanded and aria-controls naming a listbox of options
nameThe label prop; the listbox is "Suggestions for <label>".
focusTyping keeps focus in the field while the suggestions show. Choosing one returns focus to the field; Tab from the field closes them and moves on.
keyboardTyping filters the suggestions. ArrowDown moves to the first, ArrowUp to the last, and the arrows move between them; Enter and Space choose one; Escape closes them and leaves focus in the field, and the arrows open them again.
notesOn a phone the field hears no keys, so the suggestions are pressed; VoiceOver and TalkBack reach them in order after the field.

Theme tokens

color.border color.surface color.ink shadow.md space.1 space.3 text.label text.body

Example

<Combobox label="City" options={cities} bind:value={city} />