Autocomplete
An input that suggests matching options as you type.
Preview
Installation
Usage
import {
Autocomplete,
AutocompleteEmpty,
AutocompleteInput,
AutocompleteItem,
AutocompleteList,
AutocompletePopup,
AutocompleteGroup,
AutocompleteGroupLabel,
AutocompleteSeparator,
} from "@/components/ui/autocomplete"const items = [
{ value: "apple", label: "Apple" },
{ value: "banana", label: "Banana" },
{ value: "orange", label: "Orange" },
]
<Autocomplete items={items}>
<AutocompleteInput placeholder="Search..." />
<AutocompletePopup>
<AutocompleteEmpty>No results found.</AutocompleteEmpty>
<AutocompleteList>
{(item) => (
<AutocompleteItem key={item.value} value={item}>
{item.label}
</AutocompleteItem>
)}
</AutocompleteList>
</AutocompletePopup>
</Autocomplete>API Reference
Autocomplete
Root component managing state and providing context to child components.
AutocompleteInput
Input field with support for icons and action buttons.
AutocompletePopup
Popup container for suggestions and results.
AutocompleteList
Scrollable container for autocomplete items.
AutocompleteItem
Individual selectable item in the list.
AutocompleteEmpty
Message displayed when no results match.
AutocompleteGroup
Container for grouped items.
AutocompleteGroupLabel
Label for an item group.
AutocompleteSeparator
Visual separator between groups.
Renders a horizontal line divider without additional props.
Examples
Disabled
With Label
Inline Autocomplete
Autofill the input with the highlighted item while navigating with arrow keys.
Auto Highlight
Automatically highlight the first matching option when results appear.
With Clear Button
With Trigger and Clear Buttons
With Groups
Organize items into categorized sections for better organization.
Limit Results
Restrict displayed results and show only a set number of matches.
Async Search
Load suggestions dynamically based on user input.
Form Integration
Use autocomplete within forms for controlled selection handling.
With Start Addon
Display an icon at the input start for visual context.