Skip to content
Forms

Autocomplete

Free-text input with sync or async suggestions.

Import

tsx
import { Autocomplete } from "@cooud-ui/ui";
bash
npx cooud-ui add autocomplete

Examples

API Reference

Generated from the component's exported types.

AutocompleteProps

Extends Omit< InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "onSelect" | "role" >

PropTypeDefaultDescription
options
AutocompleteOption[]Static suggestions. When omitted, provide `onSearch` to fetch suggestions for the current query asynchronously.
onSearch
(query: string) => Promise<AutocompleteOption[]>Async resolver invoked (debounced) with the current query. Return the suggestions to render. Use together with `loading` for the busy state, or let the component manage `loading` automatically when `options` is omitted.
value
stringControlled free-text value. Pair with `onValueChange`.
defaultValue
stringInitial value for uncontrolled usage.
onValueChange
(value: string) => voidCalled with the new free-text value on every keystroke or selection.
onSelect
(option: AutocompleteOption) => voidCalled when a suggestion is committed (click / Enter on a highlight).
placeholder
string"Type to search…"Placeholder for the text input.
emptyText
string"No results found."Message rendered when there are no suggestions for the query.
loading
booleanForces the busy state (spinner + skeletons). When `onSearch` is provided and this is left undefined, the component tracks pending searches itself.
debounceMs
number200Debounce, in ms, before `onSearch` fires or local filtering re-runs.
allowCustomValue
booleantrueWhen true (default), the committed value can be free text that is not in the suggestion list. When false, blurring or Enter with non-matching text reverts to the last valid value.
disabled
booleanfalseDisable the whole control.
contentClassName
stringExtra classes for the popover content.
loadingSkeletonRows
number3Number of skeleton rows to show while loading.