Autocomplete

Forms

A text input with search suggestions. Use autocomplete when users need to search or filter through a large list of options.

Import

import { Autocomplete } from "@/components/ui/autocomplete";

Usage

Product Search

Autocomplete with product options and descriptions

Country Selection

Simple autocomplete without descriptions

With Error

Autocomplete showing error state

Please select a product

Disabled

Autocomplete in disabled state

API Reference

options*
AutocompleteOption[]

Array of options with value, label, and optional description

value
string

Controlled selected value

defaultValue
string

Default selected value (uncontrolled)

onValueChange
(value: string) => void

Handler called when selection changes

onInputChange
(input: string) => void

Handler called when input text changes

label
string

Label text displayed above the input

placeholder"Search..."
string

Placeholder text

loadingfalse
boolean

Show loading indicator

allowCustomValuefalse
boolean

Allow values not in the options list

emptyMessage"No results found"
string

Message shown when no options match

error
string

Error message to display

disabledfalse
boolean

Whether the autocomplete is disabled