Combobox

import { Combobox } from "@surfaces-ui/components";

A text box that suggests as a person types: a person to hand work to, a table, a tag. Anything may be typed; a suggestion is a shortcut. The host searches (on its server, for a long list) and passes the matches back as options; the box filters nothing. The ARIA 1.2 combobox: Down and Up move through the suggestions with focus kept in the box, Enter chooses (and with none highlighted, leaves Enter to the form), Escape closes the list and then clears the box. How many suggestions there are is announced.

Props

PropTypeRequiredWhat it is
labelstringyesThe field's name, shown above it.
valuestringyesThe text in the box.
optionsobject[]yesThe suggestions for the text as it is now, best first.
loadingbooleanSuggestions are being fetched.
type"text" \"email" \"search"
placeholderstring
requiredboolean
disabledboolean
namestringThe input's name, when a form reads it.
helpstringA sentence under the field.

Callbacks

  • onChange: Every change to the text, typed or chosen. Search with it.
  • onPick: The suggestion a person chose.

Example

tsx
<Combobox
  label="Hand their work to"
  type="email"
  value=""
  placeholder="Their name or email"
  options={[{"value":"ana@example.com","label":"Ana Admin","detail":"ana@example.com"},{"value":"cleo@example.com","label":"Cleo Chen","detail":"cleo@example.com"}]}
  onChange={…}
  onPick={…}
/>