Skip to content

AutoComplete

AutoComplete is a text field that suggests completions as you type. It doesn’t filter anything itself: you pass the options for the current text, computed locally or fetched. It is an Input driving the option list shared with Select; focus stays in the input the whole time, as in the WAI-ARIA combobox pattern with list autocomplete.

Demos

Basic

The menu opens while you type (when there are options) and is as wide as the field. The first suggestion is active, so Enter picks it; ↑ / ↓ move. Picking puts the option’s label in the field. A string option is shorthand for { label, value }.

Filter and groups

Filter the options yourself; groups work as in Select. getShow decides when the menu may show: here always, so focusing the empty field lists everything. Input props such as prefix pass through.

Picking as an action

onSelect gets the picked value. With clearAfterSelect the field empties after a pick, which suits “add a label” inputs; append adds the label to the text instead of replacing it, and blurAfterSelect moves focus away.

Remote suggestions

Fetch the options as the text changes; loading shows Input’s spinner meanwhile.

Keyboard

With the menu open: ↑ / ↓ move the active suggestion (skipping disabled ones and wrapping), Enter picks it, Escape closes it. Typing reopens it, and so does ↓. Other keys edit the text. While an IME is composing, Enter confirms the composition, not a suggestion.

Props

NameTypeDefaultDescriptionVersion
optionsAutoCompleteMixedOption[]requiredSuggestions for the current text: strings, { label, value, disabled? }, or groups { type: "group", label, key, children }.Unreleased
valuestring | nullundefinedControlled value.Unreleased
defaultValuestring | nullnullInitial value when uncontrolled.Unreleased
onUpdateValue(value: string | null) => voidundefinedCalled on every edit, pick and clear.Unreleased
onSelect(value, option) => voidundefinedCalled with the picked option.Unreleased
appendbooleanfalsePicking appends the label to the text.Unreleased
clearAfterSelectbooleanfalsePicking empties the field.Unreleased
blurAfterSelectbooleanfalsePicking blurs the field.Unreleased
getShow(value: string) => booleantext isn’t emptyWhether the menu may show for this text.Unreleased
showEmptybooleanfalseShow the menu with the empty text when there are no options.Unreleased
emptyReactNodelocale “No data”The empty text.Unreleased
renderLabel(option, selected) => ReactNodeundefinedCustom label in the menu.Unreleased
placementPopoverPlacementbottom-startWhere the menu opens.Unreleased
to / zIndexSame as Popover.Unreleased

It also takes Input’s props except type, autosize, rows and showPasswordOn: size, status, clearable, loading, prefix, suffix, disabled, placeholder, ref (the input), wrapperRef and native attributes.