TypeaheadControls
interfaceSource L17Type contract for TypeaheadControls.
interface TypeaheadControlsMembers
| Name | Type |
|---|---|
search | (character: string) => number |
onKeyDown | (event: React.KeyboardEvent) => void |
reset | () => void |
Open-code aq-ui React hook for Use Typeahead.
pnpm dlx aq-ui@alpha add use-typeaheadImport the parts you need, then jump to an export for its contract.
"use client"
import { useTypeahead } from "@/hooks/use-typeahead"Type contract for TypeaheadControls.
interface TypeaheadControls| Name | Type |
|---|---|
search | (character: string) => number |
onKeyDown | (event: React.KeyboardEvent) => void |
reset | () => void |
Open-code aq-ui React hook for Use Typeahead.
function useTypeahead<T>({ items, activeIndex, onActiveIndexChange, getTextValue = (item) => String(item), timeout = 500, loop = true, disabledIndices = [], }: UseTypeaheadOptions<T>): TypeaheadControlsTypeaheadControls| Name | Type |
|---|---|
options | UseTypeaheadOptions<T> |
Type contract for UseTypeaheadOptions.
interface UseTypeaheadOptions<T>| Name | Type | Default |
|---|---|---|
items | T[] | — |
activeIndex | number | — |
onActiveIndexChange | (index: number) => void | — |
getTextValue? | (item: T) => string | (item) => String(item) |
timeout? | number | 500 |
loop? | boolean | true |
disabledIndices? | Iterable<number> | [] |
use-stable-callback