Autocomplete
Filter-as-you-type input with suggestions.
Installation
Usage
Examples
Frameworks
A longer list to filter through.
Disabled item
Options can be locked individually.
With label
Pair the field with a form label.
API reference
Autocomplete
| Prop | Type | Default |
|---|---|---|
valueControlled selected value. Use with onValueChange. | string | - |
defaultValueInitially selected value when uncontrolled. | string | - |
onValueChangeCalled when the selection changes. | (value: string) => void | - |
itemToStringLabelFormats values for display. Defaults to resolving item labels automatically. | (value: unknown) => string | - |
openControlled open state. Use with onOpenChange. | boolean | - |
defaultOpenInitially open when uncontrolled. | boolean | false |
disabledDisable the input and popup. | boolean | false |
openOnInputClickShow the popup on click. Leave off so it only appears while typing. | boolean | false |
nameIdentifies the field when the form is submitted. | string | - |
AutocompleteInput
| Prop | Type | Default |
|---|---|---|
placeholderHint text shown while empty. | string | - |
disabledDisable the input. | boolean | false |
classNameAdditional classes merged with the default input styles. | string | - |
AutocompleteContent
| Prop | Type | Default |
|---|---|---|
sidePreferred placement side. | "top" | "right" | "bottom" | "left" | "bottom" |
sideOffsetGap between input and popup. | number | 4 |
alignAlignment against the input edge. | "start" | "center" | "end" | "center" |
alignOffsetOffset along the alignment axis. | number | 0 |
renderPolymorphic render prop. Use to render a custom element instead of the default popup. | ReactElement | ((props) => ReactNode) | - |
classNameAdditional classes merged with the default popup styles. | string | - |
AutocompleteItem
| Prop | Type | Default |
|---|---|---|
valueValue set when selected. Labels display via the item text. | string | - |
disabledDisable the item. | boolean | false |
renderPolymorphic render prop. | ReactElement | ((props) => ReactNode) | - |
classNameAdditional classes merged with the default item styles. | string | - |
AutocompleteEmpty
| Prop | Type | Default |
|---|---|---|
childrenShown when the query matches nothing. | ReactNode | "No results found." |
classNameAdditional classes merged with the default empty styles. | string | - |