Skip to content
Alea0.1

Forms

ComboBox and TagField

Type to filter and pick one option, or several as removable tags.

Ant Design: AutoComplete, Select showSearch, Select mode="tags"

import { ComboBox, TagField } from '@alea/ui';

Examples

ComboBox

defaultItems filters as people type.

Free text

allowsCustomValue keeps whatever people type.

Or type your own

TagField

Several picks as tags; Backspace removes the last one.

2 of 5
  • German
  • Japanese

Props

ComboBox props

Type to filter a list and pick one (Ant's AutoComplete / Select showSearch). Pass defaultItems to filter as people type, or items to filter yourself (async search). allowsCustomValue keeps free text.

PropTypeDefaultDescription
childrenReactNode | ((item: T) => ReactNode)-Option rendering for custom items; plain {id, label} items render as options.
descriptionReactNode-Help text under the field.
emptyTextReactNode'No matches'Shown when nothing matches. Default "No matches".
errorMessageReactNode | ((v: ValidationResult) => ReactNode)-Error text, shown when invalid.
labelReactNode-The visible label.
placeholderstring-Shown while the field is empty.
size"sm" | "md" | "lg"'md'sm 32 px, md 44 px (default), lg 48 px.

TagField props

Pick several options by typing; picks show as removable tags (Ant's Select mode="tags").

PropTypeDefaultDescription
itemsrequiredSelectOption[]-The options to pick from.
allowsCustomValueboolean-Lets people add values that are not in the list (Enter).
classNamestring-Extra class names for the root element.
defaultValueKey[]-The tags to start with.
descriptionReactNode-Help text shown under the field.
isDisabledboolean-Disables every part of it.
labelReactNode-The visible label.
maxnumber-Most picks allowed.
onChange((value: Key[]) => void)-Called with the tags.
placeholderstring'Type to add…'Shown while there is no value.
styleCSSProperties-Inline styles for the root element.
valueKey[]-Picked ids (controlled).

Accessibility

  • A combobox with a listbox; the highlighted option is announced while focus stays in the field.
  • Picked tags have remove buttons named after the tag.

Keyboard

KeyDoes
TypingFilters
Arrow Down / UpMoves through suggestions
EnterPicks (or adds custom text in TagField)
EscapeCloses the list
Backspace (empty)Removes the last tag

Do and don't

Do

  • Use defaultItems to filter as people type, items to filter yourself (server search).

Don't

  • Don't use for fewer than eight options: use Select.
Tested with axe, keyboard and screen reader roles