Components / Base / Command menu

B11 · Base

Command menu

A filterable list of example commands. Choosing one writes a line. It does not leave the preview.

When to use

  • A page has many destinations and a keyboard path helps.
  • The set can be filtered by typing.

When not to use

  • There are fewer than five actions. Show them.
  • The menu would be the only way to reach a primary action.

Usage

<button type="button" aria-expanded="false">Open menu</button>
<div class="c-cmd" hidden>
  <input type="text" role="combobox" aria-label="Example commands">
  <ul role="listbox"><li role="option">Open register</li></ul>
</div>

Variants

The preview shows the form used in the gallery.

Props

NameTypeDefaultDescription
role=comboboxinput—Filters the list.
role=listbox / optionlist—The matches.
data-commandname—Written into the result line.

Keyboard

KeyAction
EnterOn the opener, or on a highlighted option, runs it.
ArrowUp / ArrowDownMoves the highlight.
EscapeCloses the menu.
TypeFilters.

Accessibility

Motion

Pattern origin

Base command menu. The gallery’s own menu uses the same keys.

Related

Number-key routerText inputSide nav