Skip to content

Autocomplete ​

Finds values by typing and shows each chosen value as a chip in the field.

base-baseinputautocomplete--tagsOpen in Storybook ↗

When to use ​

  • Links to other records: the people, places or subjects of a record.
  • Tags or keywords, where a field holds several values.
  • Lists that are too long to scan, where typing a few letters is faster.

When not to use ​

  • A short, fixed list: use a dropdown.
  • Free text: use a text input.
  • A status or category that is only shown: use a chip without a field.

Anatomy ​

  1. Field: --radius-input corners, --color-border-default border, at least --control-height high. It grows in height when the chips need more than one line.
  2. Chips: one per value, --radius-chip corners, bold --text-label. Chosen values are value chips (--color-chip-value-bg / --color-chip-value-text, from the client accent); links to records are relation chips (--color-chip-relation-bg / --color-chip-relation-text).
  3. Remove button: a ✕ at the end of each chip, while the field can be edited.
  4. Search: after the chips; typing filters the list.
  5. Chevron: opens the list; a spinner shows next to it while results load.
  6. List: a card under the field, --radius-card, --shadow-overlay. Each option shows its label and, when there is one, extra details in muted text (such as a person's dates). The focused option gets --color-accent-wash.

Variants ​

VariantWhereLooks
Multiple — the defaulttags, relationsany number of chips
Singleone linked valueone chip; the search disappears once a value is chosen and comes back when it is removed
Create optionfields that allow new valuestyping something that is not in the list offers it as an option, such as Create: "poetry"
Chip with a value boxrelations that carry a detail, such as a page numbera compact text input inside each chip
Borderlessinside another control, such as a filterno border
Read-onlyvalues that can be seen but not changedchips only: no border, no ✕, no search
Plain textread-only values that read better as textthe values as plain text, without chips
base-baseinputautocomplete--create-optionOpen in Storybook ↗

Picking the create option hands the typed value to the screen, which then adds it, for example by creating a new record.

When a read-only relation chip links to its record, it shows a pointer and changes colour on hover; clicking it opens the record.

States ​

StateWhat you seeTrigger
Emptyplaceholderno values yet
With valuesa chip per valuevalues chosen
Hoverborder darkens (--color-border-dashed)pointer
Focusfocus ring around the whole field (--color-focus-ring)click or Tab into the search
Openlist under the field; chosen values are left out of itclick, typing, ↓
Long listbelow the options: Start typing to find more options20 options or more and nothing typed
No matchesthe list says sotyped text matches no option
Loadingspinner in the fieldresults are being fetched
Disabled--color-surface-muted fill; chips without ✕the field is unavailable
Read-onlychips on their ownsee Variants
base-baseinputautocomplete--statesOpen in Storybook ↗

By default, typing matches every word you type, in any order and ignoring case: fic hist finds historical fiction.

Choosing or removing a value only changes the field. The form or inline editor around it saves the change.

Keyboard & accessibility ​

KeyIn the search
↓ / ↑opens the list; next / previous option
Enterpicks the focused option
Backspacewith nothing typed: removes the last chip
Escapecloses the list
Tabmoves on

Tab stops on each chip's ✕ before it reaches the search.

  • The search is a role="combobox" with aria-expanded and aria-controls; the list is a role="listbox" with role="option" items that carry aria-selected.
  • Each ✕ is a role="button" named Remove {value}, such as Remove fantasy.
  • The search field announces the chosen values.

Content ​

  • The label names what the values are, as a plural noun where it holds several: Genres, Creators.
  • The placeholder says what to search for: Search for a genre…
  • Fixed texts: Remove {value}, Start typing to find more options.
  • The create option quotes the typed text: Create: "poetry".

Chip & badge · Dropdown · Text input · Loading · Accessibility

Powered by Elody - Open Source Semantic Data Platform