Hone UI
Components

Autocomplete

A text field with a list of suggestions.

Autocomplete suggests options as the user types. Render the field yourself with renderInput.

import Autocomplete from '@hone-ui/react/Autocomplete';

Examples

<Autocomplete
  options={['Apple', 'Banana', 'Cherry', 'Mango']}
  renderInput={(params) => <TextField {...params} label="Fruit" />}
/>

Props

PropTypeDefaultDescription
optionsT[]requiredThe choices.
renderInput(params) => noderequiredSpread params onto a TextField.
value, defaultValueT, string, nullnullThe value.
onChange(event, value, reason) => voidselectOption, createOption or clear.
inputValue, onInputChangeThe text in the input.
open, onOpen, onCloseThe popup.
getOptionLabel, isOptionEqualToValuefunctionsHow options read and compare.
getOptionDisabled, filterOptions, renderOptionfunctionsPer-option control.
multiple, disableCloseOnSelectbooleanfalsePick several options, shown as chips.
freeSolobooleanfalseAny text is a value. No popup when nothing matches.
disabled, disableClearable, openOnFocus, loadingbooleanfalseStandard.
clearOnEscapebooleanfalseEscape with the list closed clears the field.
noOptionsText, loadingTextReactNode'No options', 'Loading…'Popup messages.
size, fullWidth'medium', falseThe field's size and width.
sx, className, style, refStandard, on the root.

Notes

  • id goes to the input, as in the reference API.
  • renderTags, limitTags, groupBy, autoHighlight and the replaceable components are not supported.

clearOnEscape changes only the closed list. With the list open, Escape closes it and keeps the text, so a second press clears. The change reports reason 'clear'.

Accessibility

The input is a combobox linked to its list: arrow keys, Enter and Escape work, and screen readers announce the options.

On this page