Skip to content
Eskais UI

Forms

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

Suggestions help; any text is valid.

Installation

npx shadcn@latest add @eskais/autocomplete
npm packageslucide-react

Usage

Import
import {  Autocomplete,  AutocompleteClear,  AutocompleteContent,  AutocompleteControl,  AutocompleteEmpty,  AutocompleteGroup,  AutocompleteGroupLabel,  AutocompleteInput,  AutocompleteItem,  AutocompleteItemIcon,  AutocompleteItemText,  AutocompleteList,  AutocompleteSeparator,  AutocompleteStatus,  AutocompleteTrigger,  createAutocompleteController,  useAsyncOptions,} from "@/components/ui/autocomplete"

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.

AutocompleteTrigger

PropTypeDefault
tooltipControlTooltipOption–

Also takes every prop of UI SDK AutocompleteTrigger.

AutocompleteClear

PropTypeDefault
tooltipControlTooltipOption–

Also takes every prop of UI SDK AutocompleteClear.

AutocompleteGroupLabel

Takes every prop of UI SDK AutocompleteGroupLabel.

AutocompleteSeparator

Takes every prop of UI SDK AutocompleteSeparator.

Other exports

AutocompleteAutocompleteGroupAutocompleteListcreateAutocompleteControlleruseAsyncOptionstype AsyncOptionsStatustype AutocompleteControllertype AutocompleteValueChangeReason

Accessibility

  • 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.