Skip to content
Alea0.1

Forms

Autocomplete

Search with suggestions: static or loaded as people type, grouped, with matches highlighted and recent searches when empty.

Ant Design: AutoComplete

import { Autocomplete, Highlight } from '@alea/ui';

Examples

Grouped suggestions

Matches are highlighted; recent searches show when the field is empty.

Loaded as you type

Debounced, with a spinner, and stale requests are cancelled through the AbortSignal.

Props

Autocomplete props

Search with suggestions: static or loaded as you type, grouped, matches highlighted, recent searches when empty (MUI Autocomplete, Ant AutoComplete).

PropTypeDefaultDescription
classNamestring-Extra class names for the root element.
debouncenumber250Wait this long after typing before loading, in ms. Default 250.
descriptionReactNode-Help text shown under the field.
itemsAutocompleteItem[]-Static items, filtered as people type.
labelReactNode-The visible label.
loadItems((query: string, signal: AbortSignal) => Promise<AutocompleteItem[]>)-Or load matches as people type (debounced); return the items.
minCharsnumber1Least characters before suggesting. Default 1.
onSelect((item: AutocompleteItem) => void)-Called with the picked item.
onSubmit((text: string) => void)-Called on Enter with free text (a search).
placeholderstring'Search'Shown while there is no value.
recentAutocompleteItem[]-Shown when the field is empty and focused: recent searches or suggestions.

Highlight props

PropTypeDefaultDescription
queryrequiredstring-The words to mark (case-insensitive).
textrequiredstring-The full text.

Accessibility

  • A combobox: the list is announced with its count, and the highlighted option is read as people arrow through it.
  • While loading, a spinner with a label shows; results replace it without moving focus.
  • Enter with nothing highlighted submits the free text.

Keyboard

KeyDoes
Arrow Down / UpMove through suggestions
EnterPicks the suggestion, or submits the text
EscapeCloses, then clears

Do and don't

Do

  • Debounce remote searches (the default is 250 ms) and cancel stale ones: the component passes an AbortSignal.

Don't

  • Don't use it to choose from a fixed short list: use Select or ComboBox.

In Figma

Autocomplete with Empty, Typing, Results, Loading and No results states.

Tested with axe, keyboard and screen reader roles