Reference headless
combobox
# ComboboxContext
Type Parameters
T
Members
errorerror: Error | nullMost recent fetcher error, if any.
filteredfiltered: readonly T[]Filtered subset shown in the listbox.
highlightedIdhighlightedId: string | nullId of the currently highlighted option, or null.
optionsoptions: readonly T[]Source list of options (sync mode). For async, mirrors the latest fetch.
pageSizepageSize: numberPage step for PageUp / PageDown navigation.
queryquery: stringCurrent input string.
statusstatus: ComboboxStatusAsync fetch lifecycle. Always 'idle' in sync mode.
tokentoken: numberMonotonic token incremented on every INPUT.CHANGE; used to drop stale fetches.
valuevalue: T | nullCurrently selected option, or null.
# ComboboxController
Type Parameters
T
Members
contextreadonly context: Readonly<ComboboxContext<T>>disabledreadonly disabled: booleanfilteredreadonly filtered: readonly T[]highlightedIdreadonly highlightedId: string | nullidreadonly id: stringinputreadonly input: AttachmentinputIdreadonly inputId: stringisOpenreadonly isOpen: booleanlistboxreadonly listbox: AttachmentlistboxIdreadonly listboxId: stringmachinereadonly machine: ComboboxMachine<T>queryreadonly query: stringrootreadonly root: Attachmentstatereadonly state: ComboboxStatestatusreadonly status: ComboboxStatustriggerreadonly trigger: Attachmentvaluereadonly value: T | nullclose()close(): void###### Returns
voidopen()open(): void###### Returns
voidoption()option(option): AttachmentoptionElementId()optionElementId(optionId): string###### Parameters
###### optionId
string###### Returns
stringreset()reset(): void###### Returns
voidselect()select(option): voidUser-action selection — fires onValueChange and closes the listbox.
###### Parameters
###### option
T###### Returns
voidsetDisabled()setDisabled(disabled): void###### Parameters
###### disabled
boolean###### Returns
voidsetValue()setValue(value): voidProgrammatic value update — works in any state, does not transition.
###### Parameters
###### value
T|null###### Returns
voidsubscribe()subscribe(listener): () => void###### Parameters
###### listener
(
snapshot) =>void###### Returns
() =>
void
# ComboboxOption
Structural shape an option must satisfy. Most consumers pass typed domain objects (User, Product, …) — id and label are the floor; everything else propagates as T.
Members
disabled?readonly optional disabled?: booleanidreadonly id: stringlabelreadonly label: string
# CreateComboboxOptions
Type Parameters
T
Members
defaultQuery?optional defaultQuery?: string###### Inherited from
CreateComboboxInput.defaultQuerydefaultValue?optional defaultValue?: T | null###### Inherited from
CreateComboboxInput.defaultValuedisabled?optional disabled?: boolean###### Inherited from
CreateComboboxInput.disabledfilter?optional filter?: (options, query) => readonly T[]Optional sync filter. Receives
(options, query)and returns a subset. Default: case-insensitivelabelsubstring match.###### Parameters
###### options
readonly
T[]###### query
string###### Returns
readonly
T[]###### Inherited from
CreateComboboxInput.filterid?optional id?: stringonOpenChange?optional onOpenChange?: (open) => voidCalled when the open state changes.
###### Parameters
###### open
boolean###### Returns
voidonQueryChange?optional onQueryChange?: (query) => voidCalled on every input change.
###### Parameters
###### query
string###### Returns
voidonValueChange?optional onValueChange?: (value) => voidCalled when the selected value changes (user-initiated).
###### Parameters
###### value
T|null###### Returns
voidoptions?optional options?: readonly T[]###### Inherited from
CreateComboboxInput.optionspageSize?optional pageSize?: numberPage step for PageUp/PageDown. Defaults to 10.
###### Inherited from
CreateComboboxInput.pageSize
# Attachment
Attachment = (node) => void | (() => void)Parameters
nodeHTMLElement
Returns
void | (() => void)# ComboboxEvent
ComboboxEvent<T> = { type: "INPUT.FOCUS"; } | { type: "INPUT.BLUR"; } | { type: "INPUT.CHANGE"; value: string; } | { type: "INPUT.ESCAPE"; } | { type: "INPUT.ENTER"; } | { direction: NavigateDirection; type: "INPUT.NAVIGATE"; } | { id: string; type: "OPTION.HIGHLIGHT"; } | { option: T; type: "OPTION.SELECT"; } | { type: "TRIGGER.CLICK"; } | { type: "OPEN"; } | { type: "CLOSE"; } | { options: ReadonlyArray<T>; token: number; type: "FETCH.RESOLVE"; } | { error: Error; token: number; type: "FETCH.REJECT"; } | { token: number; type: "FETCH.LOADING"; } | { type: "SET.VALUE"; value: T | null; } | { type: "RESET"; } | { type: "DISABLE"; } | { type: "ENABLE"; }All events the Combobox machine can receive.
Type Parameters
T
# ComboboxMachine
ComboboxMachine<T> = Machine<ComboboxContext<T>, ComboboxEvent<T>, ComboboxState>Type Parameters
T
# ComboboxState
ComboboxState = "idle" | "open" | "disabled"# ComboboxStatus
ComboboxStatus = "idle" | "loading" | "error"Async fetch lifecycle.
# NavigateDirection
NavigateDirection = "next" | "prev" | "first" | "last" | "page-next" | "page-prev"Keyboard navigation directions.
# createCombobox ( )
createCombobox<T>(options?): ComboboxController<T>Create a Combobox controller plus its {@attach}-compatible attachments.
Type Parameters
T
Parameters
options?CreateComboboxOptions<T> = {}
Returns
ComboboxController<T>