Inputs

Combobox

An input whose option list anchors beneath it with CSS anchor positioning. Filters as you type.

Examples

Combobox

Ada Lovelace Owner
Mika Kim Editor
Jun Rao Viewer

Anatomy

.comboboxWrapper. Makes its .input the anchor for the list.
> input.inputThe text field, with role="combobox", aria-expanded and aria-controls pointing at the list.
> .combobox-listFrosted listbox, popover="manual". Anchors below the input at its width and flips above when there is no room.
> [role=option]One row per option: an avatar or icon, the label, and an optional <small> pushed to the end.

API

AttributeValuesDescription
aria-selectedtrueOn an option: the highlighted row, with a fill and an accent edge at the start. aequitas.js moves it with the arrow keys.
aria-expandedtruefalseOn the input: whether the list is open. aequitas.js keeps it in sync.
aria-controls<id>On the input: the id of the .combobox-list.
popovermanualOn the list. Required: the list is a popover, hidden until showPopover().
data-value<text>On an option: the value written into the input when it is picked. Default textContent.

Behaviour

aequitas.js opens the list on focus and as you type, hides options whose text does not contain the input's value and highlights the first match; ↑/↓ move the highlight, and Enter or a click writes the option's data-value (or its text) into the input and fires change. Esc and blur close the list and aria-expanded follows. Without it, the list is a plain popover: open, filter and pick are up to you.

From aequitas.js. It initialises itself and enhances markup added later on its own, so it works the same in an SPA.

Accessibility

  • Label the input with <label for>, and give the list role="listbox" with role="option" rows. aequitas.js gives the input role="combobox", aria-expanded, aria-autocomplete and aria-controls (and the list an id if it has none); write them yourself without it.
  • Focus stays in the input; aequitas.js points aria-activedescendant at the highlighted option (giving it an id if it has none), so screen readers announce it as it moves.
  • Set autocomplete="off" so the browser's own suggestions do not cover the list.
KeyEffect
↓ / ↑Opens the list and moves the highlight through the visible options, wrapping at the ends.
EnterPicks the highlighted option and closes the list.
EscCloses the list. Inside a dialog only the list: a second Esc closes the dialog.
Jump to
ProportionFoundations
MaterialFoundations
PresetsFoundations
ShellLayouts · Application
Container and stacksLayouts · Pages
SplitLayouts · Pages
Grid, bento, masonryLayouts · Pages
Switcher and rowLayouts · Pages
↑↓Move↵OpenescClose