Autocomplete
Autocomplete user input with any list of options
Import
Source
Docs
Package
Usage
Controlled
Data prop
Autocomplete support two different data formats:
- An array of strings
- An array of objects with required
value
property and any other additional properties
Dynamic data
Group options
Custom item component
Autocomplete item component and filtering logic can be changed. To do so:
- Add extra props to
data
objects - Create
filter
function which determines whether item should be added to the search results - Provide
itemComponent
which will consumedata
objects
Limit amount of options
By default, Autocomplete will render 5 items at a time, to change that set limit
prop:
Dropdown position
By default, dropdown is placed below the input and when there is not enough space, it flips to be above the input.
To change this behavior, set dropdownPosition
prop:
DropdownPosition
Animations
By default, dropdown animations are turned off to increase responsiveness. To enable animations set the following optional props:
transition
– premade transition name or custom transition styles object, see Transition component for all available optionstransitionDuration
– transition duration in ms, defaults to 0transitionTimingFunction
– defaults totheme.transitionTimingFunction
With icon
Invalid state and error
Field is required
Disabled state
Input props
Radius
xs
sm
md
lg
xl
Size
xs
sm
md
lg
xl
Get input ref
Accessibility
Provide aria-label
in case component does not have a label for screen reader support: