Autocomplete
UI SDK Autocomplete styled as a field: free text with suggestions that filter as you type, matches marked, Clear and Trigger buttons with tooltips, async suggestions through useAsyncOptions, floating labels and FormField binding.
Example
Clear
Suggestions help; any text is valid.
autocomplete-demo.tsxCopy code
Installation
Copy code
Usage
ImportCopy code
Reach for it when any text is valid and suggestions only help: a search box, a city, a tag name. When the value must be an option, use Combobox.
API reference
AutocompleteControl
Takes <div> attributes and render.
AutocompleteInput
AutocompleteTrigger
| Prop | Type | Default |
|---|---|---|
tooltip | ControlTooltipOption | – |
Also takes every prop of UI SDK AutocompleteTrigger.
AutocompleteClear
| Prop | Type | Default |
|---|---|---|
tooltip | ControlTooltipOption | – |
Also takes every prop of UI SDK AutocompleteClear.
AutocompleteContent
AutocompleteEmpty
AutocompleteStatus
AutocompleteItem
AutocompleteItemIcon
AutocompleteItemText
AutocompleteGroupLabel
AutocompleteSeparator
Other exports
AutocompleteAutocompleteGroupAutocompleteListcreateAutocompleteControlleruseAsyncOptionstype AsyncOptionsStatustype AutocompleteControllertype AutocompleteValueChangeReasonAccessibility
- An input with the combobox role; arrows highlight a suggestion while focus stays in the input, Enter fills it in, Escape closes.
- The matched part of each suggestion is marked in a heavier weight, not only a colour.
- Clear and Show suggestions are icon buttons named for agents and screen readers, with the name in a tooltip.
Agent actions
Agents find it by its label and set any text with setValue.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.