State
The autocomplete state drives the behavior of the experience.
The state is passed to all lifecycle hooks so that you can customize the behavior.
Guides
Setting an initial state
You can instantiate autocomplete with an initial state with the initialState
prop.
Listening state changes
You can create your own API based on the autocomplete state with the onStateChange
prop.
Reference
State
highlightedIndex
number | null
| defaults tonull
The highlighted item index.
query
string
| defaults to""
The query of the input.
completion
string | null
| defaults tonull
The completion of the input.
isOpen
boolean
| defaults tofalse
Whether the dropdown is opened.
suggestions
Suggestion[]
| defaults to[]
The suggestions of the experience.
status
'idle' | 'loading' | 'stalled' | 'error'
| defaults toidle
The status of the experience.
context
object
| defaults to{}
The autocomplete context passed to lifecycle hooks.
Learn more on the context page.
Setters
setHighlightedIndex
(value: number | null) => void
Sets the highlighted item index. Pass null
to unselect items.
setQuery
(value: string) => void
Sets the query.
setSuggestions
(value: any) => void
Sets the suggestions.
setIsOpen
(value: boolean) => void
Sets the open state of the dropdown.
setStatus
(value: 'idle' | 'loading' | 'stalled' | 'error') => void
Sets the status of the experience.
setSuggestions
(value: Suggestion[]) => void
Sets the suggestions of the experience.
setContext
(value: object) => void
Sets the context passed in the lifecycle hooks.
Learn more on the context page.