Autocomplete API - Material UI (original) (raw)
options*
array
-
A list of options that will be shown in the Autocomplete.
renderInput*
func
-
Render the input.
Note: The renderInput prop must return a TextField component or a compatible custom component that correctly forwards InputProps.ref and spreads inputProps. This ensures proper integration with the Autocomplete's internal logic (e.g., focus management and keyboard navigation).
Avoid using components like DatePicker or Select directly, as they may not forward the required props, leading to runtime errors or unexpected behavior.
Signature:function(params: object) => ReactNode
autoComplete
bool
false
If true, the portion of the selected suggestion that the user hasn't typed, known as the completion string, appears inline after the input cursor in the textbox. The inline completion string is visually highlighted and has a selected state.
autoHighlight
bool
false
If true, the first option is automatically highlighted.
autoSelect
bool
false
If true, the value is updated when the input loses focus under one of these conditions:
- An option highlighted via keyboard navigation or autoHighlight is selected. Hover and touch highlights are ignored. - Otherwise, in freeSolo mode, the typed text becomes the value.
blurOnSelect
'mouse'
| 'touch'
| bool
false
Control if the input should be blurred when an option is selected:
falsethe input is not blurred.truethe input is always blurred.touchthe input is blurred after a touch event.mousethe input is blurred after a mouse event.
classes
object
-
Override or extend the styles applied to the component.
See CSS classes API below for more details.
clearIcon
node
The icon to display in place of the default clear icon.
clearOnBlur
bool
!props.freeSolo
If true, the input's text is cleared on blur if no value is selected.
Set it to true if you want to help the user enter a new value. Set it to false if you want to help the user resume their search.
clearOnEscape
bool
false
If true, clear all values when the user presses escape and the popup is closed.
clearText
string
'Clear'
Override the default text for the clear icon button.
For localization purposes, you can use the provided translations.
closeText
string
'Close'
Override the default text for the close popup icon button.
For localization purposes, you can use the provided translations.
defaultValue
any
props.multiple ? [] : null
The default value. Use when the component is not controlled.
disableClearable
bool
false
If true, the input can't be cleared.
disableCloseOnSelect
bool
false
If true, the popup won't close when a value is selected.
disabled
bool
false
If true, the component is disabled.
disabledItemsFocusable
bool
false
If true, will allow focus on disabled items.
disableListWrap
bool
false
If true, the list box in the popup will not wrap focus.
disablePortal
bool
false
If true, the Popper content will be under the DOM hierarchy of the parent component.
filterOptions
func
createFilterOptions()
A function that determines the filtered options to be rendered on search.
Signature:function(options: Array<Value>, state: object) => Array<Value>
optionsThe options to render.stateThe state of the component.
filterSelectedOptions
bool
false
If true, hide the selected options from the list box.
forcePopupIcon
'auto'
| bool
'auto'
Force the visibility display of the popup icon.
freeSolo
bool
false
If true, the Autocomplete is free solo, meaning that the user input is not bound to provided options.
fullWidth
bool
false
If true, the input takes up the full width of its container.Autocomplete treats undefined and false differently. If undefined, the inner input takes up the full width of its container. If false, the inner input is restricted to its intrinsic width.
getLimitTagsText
func
(more) => `+${more}`
The label to display when the tags are truncated (limitTags).
Signature:function(more: number) => ReactNode
moreThe number of truncated tags.
getOptionDisabled
func
-
Used to determine the disabled state for a given option.
Signature:function(option: Value) => boolean
option: ValueThe option to test.
getOptionKey
func
-
Used to determine the key for a given option. This can be useful when the labels of options are not unique (since labels are used as keys by default).
Signature:function(option: Value) => string | number
optionThe option to get the key for.
getOptionLabel
func
(option) => option.label ?? option
Used to determine the string value for a given option. It's used to fill the input (and the list box options if renderOption is not provided).
If used in free solo mode, it must accept both the type of the options and a string.
Signature:function(option: Value | string) => string
groupBy
func
-
If provided, the options will be grouped under the returned string. The groupBy value is also used as the text for group headings when renderGroup is not provided.
Signature:function(option: Value) => string
optionThe Autocomplete option.
handleHomeEndKeys
bool
!props.freeSolo
If true, the component handles the "Home" and "End" keys when the popup is open. It should move focus to the first option and last option, respectively.
id
string
-
This prop is used to help implement the accessibility logic. If you don't provide an id it will fall back to a randomly generated one.
includeInputInList
bool
false
If true, the highlight can move to the input.
inputValue
string
-
The input value.
isOptionEqualToValue
func
-
Used to determine if the option represents the given value. Uses strict equality by default. ⚠️ Both arguments need to be handled, an option can only match with one value.
Signature:function(option: Value, value: Value | string) => boolean
optionThe option to test.valueThe value to test against.
limitTags
integer
-1
The maximum number of tags that will be visible when not focused. Set -1 to disable the limit.
loading
bool
false
If true, the component is in a loading state. This shows the loadingText in place of suggestions (only if there are no suggestions to show, for example options are empty).
loadingText
node
'Loading…'
Text to display when in a loading state.
For localization purposes, you can use the provided translations.
multiple
bool
false
If true, value must be an array and the menu will support multiple selections.
noOptionsText
node
'No options'
Text to display when there are no options.
For localization purposes, you can use the provided translations.
onChange
func
-
Callback fired when the value changes.
Signature:function(event: React.SyntheticEvent, value: Value | Array<Value>, reason: string, details?: string) => void
eventThe event source of the callback.valueThe new value of the component.reasonOne of "createOption", "selectOption", "removeOption", "blur" or "clear".
onClose
func
-
Callback fired when the popup requests to be closed. Use in controlled mode (see open).
Signature:function(event: React.SyntheticEvent, reason: string) => void
eventThe event source of the callback.reasonCan be:"toggleInput","escape","selectOption","removeOption","blur".
onHighlightChange
func
-
Callback fired when the highlight option changes.
Signature:function(event: React.SyntheticEvent, option: Value, reason: string) => void
eventThe event source of the callback.optionThe highlighted option.reasonCan be:"keyboard","mouse","touch".
onInputChange
func
-
Callback fired when the input value changes.
Signature:function(event: React.SyntheticEvent, value: string, reason: string) => void
eventThe event source of the callback.valueThe new value of the text input.reasonCan be:"input"(user input),"reset"(programmatic change),"clear","blur","selectOption","removeOption"
onOpen
func
-
Callback fired when the popup requests to be opened. Use in controlled mode (see open).
Signature:function(event: React.SyntheticEvent) => void
eventThe event source of the callback.
open
bool
-
If true, the component is shown.
openOnFocus
bool
false
If true, the popup will open on input focus.
openText
string
'Open'
Override the default text for the open popup icon button.
For localization purposes, you can use the provided translations.
popupIcon
node
The icon to display in place of the default popup icon.
readOnly
bool
false
If true, the component becomes readonly. It is also supported for multiple tags where the tag cannot be deleted.
renderGroup
func
-
Render the group.
Signature:function(params: AutocompleteRenderGroupParams) => ReactNode
paramsThe group to render.
renderOption
func
-
Render the option, use getOptionLabel by default.
Signature:function(props: object, option: Value, state: object, ownerState: object) => ReactNode
propsThe props to apply on the li element.optionThe option to render.stateThe state of each option.ownerStateThe state of the Autocomplete component.
renderValue
func
-
Renders the selected value(s) as rich content in the input for both single and multiple selections.
Signature:function(value: AutocompleteRenderValue<Value, Multiple, FreeSolo>, getItemProps: function, ownerState: object) => ReactNode
valueThevalueprovided to the component.getItemPropsThe value item props.ownerStateThe state of the Autocomplete component.
resetHighlightOnMouseLeave
bool
false
If true, clears an option highlighted by mouse movement when the mouse leaves the listbox. This behavior will be enabled by default in the next major version.
selectOnFocus
bool
!props.freeSolo
If true, the input's text is selected on focus. It helps the user clear the selected value.
size
'small'
| 'medium'
| string
'medium'
The size of the component.
slotProps
{ chip?: func
| object, clearIndicator?: func
| object, listbox?: func
| object, paper?: func
| object, popper?: func
| object, popupIndicator?: func
| object, root?: func
| object }
{}
The props used for each slot inside.
slots
{ clearIndicator?: elementType, listbox?: elementType, paper?: elementType, popper?: elementType, popupIndicator?: elementType, root?: elementType }
{}
The components used for each slot inside.
sx
Array<func
| object
| bool>
| func
| object
-
The system prop that allows defining system overrides as well as additional CSS styles.
See the `sx` page for more details.
value
any
-
The value of the autocomplete.
The value must have reference equality with the option in order to be selected. You can customize the equality behavior with the isOptionEqualToValue prop.