React Native · Components
Autocomplete
Text box that filters suggestions as you type.
4 exports
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
Preview
Code
Events
- Events appear here when you interact with the preview.
AutocompleteField: tag input and required field
Import
Autocomplete
componentText box that filters suggestions as you type. Uses the same options, list and loading modes as Select.
- Since the keyboard stays open, suggestions open right below the box in the page flow (not a bottom sheet); rows are thumb-sized.
- With
allowCustomValuetext not in the list also becomes a value; the keyboard's "Done/Enter" adds it. - With
multipleselected items become tags in the box; removed with ✕.
Examples
SingleAutocompleteProps
interfaceSingle selection.
Extends: FieldProps
| Name | Type | Default | Description |
|---|---|---|---|
multiple? | false | Single selection. | |
value? | string | Selected value (controlled). | |
defaultValue? | string | Initial value. | |
onValueChange? | (value: string, item: SelectItem | undefined) => void | When the selection changes. | |
items? | SelectItemsSource | Suggestions: an array, a Promise or a function called once. | |
loadItems? | SelectLoader | Function that searches and paginates on the server. | |
allowCustomValue? | boolean | false | Text not in the list also becomes a value (tags, email recipients). |
openOnFocus? | boolean | false | Should the list open on focus (without typing)? |
inputValue? | string | Text in the box, for controlled use. | |
onInputChange? | (text: string) => void | When the text in the box changes. | |
placeholder? | string | Placeholder. | |
emptyMessage? | ReactNode | When there are no suggestions. | |
icon? | IconProp | Icon at the start of the box. | |
clearable? | boolean | true | Clear button. |
open? | boolean | Whether the list is open, for controlled use. | |
onOpenChange? | (open: boolean) => void | When the list opens or closes. | |
variant? | FieldVariant | "outline" | Field variant. |
aria-label? | string | Screen reader name; give it if there is no visible label. | |
style? | StyleProp<ViewStyle> | Container style. |
MultiAutocompleteProps
interfaceMultiple selection: selected items become tags in the box.
Extends: FieldProps
| Name | Type | Default | Description |
|---|---|---|---|
multiple | true | Multiple selection. | |
value? | readonly string[] | Selected values (controlled). | |
defaultValue? | readonly string[] | Initial values. | |
onValueChange? | (value: string[], items: SelectItem[]) => void | When the selection changes. | |
items? | SelectItemsSource | Suggestions: an array, a Promise or a function called once. | |
loadItems? | SelectLoader | Function that searches and paginates on the server. | |
allowCustomValue? | boolean | false | Text not in the list also becomes a value (tags, email recipients). |
openOnFocus? | boolean | false | Should the list open on focus (without typing)? |
inputValue? | string | Text in the box, for controlled use. | |
onInputChange? | (text: string) => void | When the text in the box changes. | |
placeholder? | string | Placeholder. | |
emptyMessage? | ReactNode | When there are no suggestions. | |
icon? | IconProp | Icon at the start of the box. | |
clearable? | boolean | true | Clear button. |
open? | boolean | Whether the list is open, for controlled use. | |
onOpenChange? | (open: boolean) => void | When the list opens or closes. | |
variant? | FieldVariant | "outline" | Field variant. |
aria-label? | string | Screen reader name; give it if there is no visible label. | |
style? | StyleProp<ViewStyle> | Container style. |
Props of Autocomplete (same names as web).
Extends: FieldProps
| Name | Type | Default | Description |
|---|---|---|---|
multiple? | false | true | Single selection. | |
value? | string | readonly string[] | Selected value (controlled). | |
defaultValue? | string | readonly string[] | Initial value. | |
onValueChange? | (value: string, item: SelectItem | undefined) => void | (value: string[], items: SelectItem[]) => void | When the selection changes. | |
items? | SelectItemsSource | Suggestions: an array, a Promise or a function called once. | |
loadItems? | SelectLoader | Function that searches and paginates on the server. | |
allowCustomValue? | boolean | false | Text not in the list also becomes a value (tags, email recipients). |
openOnFocus? | boolean | false | Should the list open on focus (without typing)? |
inputValue? | string | Text in the box, for controlled use. | |
onInputChange? | (text: string) => void | When the text in the box changes. | |
placeholder? | string | Placeholder. | |
emptyMessage? | ReactNode | When there are no suggestions. | |
icon? | IconProp | Icon at the start of the box. | |
clearable? | boolean | true | Clear button. |
open? | boolean | Whether the list is open, for controlled use. | |
onOpenChange? | (open: boolean) => void | When the list opens or closes. | |
variant? | FieldVariant | "outline" | Field variant. |
aria-label? | string | Screen reader name; give it if there is no visible label. | |
style? | StyleProp<ViewStyle> | Container style. |