Skip to content

Search

Start typing to search.


Show all pages

Documentation

controls

Combobox

A text input with a list of suggestions that narrows as people type.

Rich widgetNeeds a script for its behavior.

Usage

An input with role="combobox" and a listbox of options with popover="manual". Typing filters the list; an option with aria-disabled="true" shows but cannot be chosen.

  • Anna de Boer
  • Bram Visser
  • Chloé Martin
  • Daan Smit
  • Emma Mulder (on leave)
HTML

Examples

Values that differ from the label

Put the value to fill in on data-value when it differs from what the option shows.

  • Station, main entrance
  • College, bike shed
  • Office park, gate B

Type part of a name, or any address.

HTML

Options can be links (<a role="option" href>); Enter or a click follows the link. data-autoselect makes the first match active, so Enter takes it at once.

HTML

Guidance and accessibility

When to use

  • Use a combobox when people pick from a long list they know by name, such as instructors or addresses, and typing is faster than scrolling.
  • People may still type a value that is not in the list. When only listed values are allowed, check the value when the form is sent.
  • For a handful of fixed options, use a select or radio buttons.

Results from your own code

For search, give the root data-filter="none" and render the options yourself on each input event, for example ranked results from an index. The script follows the changes to the list and keeps the keyboard, the active option and aria-expanded in step. Leave popover off the listbox when the results are part of the page, such as in a search dialog: the list then shows while it has options, and Escape is left to the dialog. The search on this site works this way.

Accessibility

  • It follows the WAI-ARIA combobox pattern with a listbox; ca-combobox.js provides the behavior. Focus stays in the input, and aria-activedescendant tells screen readers which option is active.
  • ArrowDown opens the list and moves down, ArrowUp moves up, Enter fills in the active option, and Escape closes the list or, when it is closed, clears the input.
  • Give the input a visible <label> and the listbox an aria-label.
  • Set autocomplete="off", so the browser’s own suggestions do not cover the list.
  • The list opens in the top layer, so a container with overflow: hidden does not cut it off. Browsers without CSS anchor positioning show it in the middle of the screen.

Classes

Generated from the component contract. Parts use __, modifiers use --.

Classes of the combobox component
ClassKindUse it for
ca-comboboxComponentWrapper around the input and its list; the list opens under the input.
ca-combobox__listboxPartThe role="listbox" of options, a manual popover anchored under the input.
ca-combobox__optionPartOne role="option". The active one has aria-selected="true".

Skins

The same markup, dressed by each skin. Structure and behavior stay the same; only the look changes.

Base skin

Neutral grayscale starting point; product skins extend it and change what differs.

  • Anna de Boer
  • Bram Visser
  • Chloé Martin
  • Daan Smit
  • Emma Mulder (on leave)

Calaca skin

The Calaca UI brand: hueso paper and tinta ink, cempasúchil marigold, rosa and jade.

  • Anna de Boer
  • Bram Visser
  • Chloé Martin
  • Daan Smit
  • Emma Mulder (on leave)

Proof skin

Pilot skin pushed far from base: square, heavy, offset shadows, larger targets.

  • Anna de Boer
  • Bram Visser
  • Chloé Martin
  • Daan Smit
  • Emma Mulder (on leave)

Crossview skin

The CrossView proofing table: cool ground, bond-paper sheets, rule-grey hairlines, one red mark.

  • Anna de Boer
  • Bram Visser
  • Chloé Martin
  • Daan Smit
  • Emma Mulder (on leave)

Framework notes

Link the prebuilt stylesheet of your skin next to your brand theme. No build step.

HTML
<link rel="stylesheet" href="theme.css" />
<link rel="stylesheet" href="ca-base.css" />