Skip to content

useTypeahead

@astryxdesign/core v0.7.1 · useTypeahead

Parameters ​

NameTypeDefaultDescription
optionsUseTypeaheadOptions—Configuration object.
options.getItemLabels() => ReadonlyArray<string | null | undefined>—Returns the item labels in DOM order. A null or empty entry marks a non-matchable slot and keeps indices aligned with the caller's items.
options.onMatch(index: number) => void—Called with the index of the matched item so the caller can focus or select it; typically useListFocus's focusItem.
options.getCurrentIndex() => number() => -1The index to search from, usually the focused item, so repeated presses of one letter cycle through matches. A negative value means nothing is current.
options.resetMsnumber750Milliseconds of inactivity after which the typed buffer resets.
options.isDisabled(index: number) => boolean—Whether an index should be skipped, e.g. disabled items.

Returns ​

NameTypeDescription
onKeyDown(event: KeyboardEvent) => booleanKeydown handler. Returns true when it consumed a printable character, so the caller can stop its own key handling.
reset() => voidClears the pending buffer, e.g. when the collection closes.