Skip to content
Components

Command palette

Spotlight-style search with global ⌘K shortcut. Native dialog + filterable list.

New Keyboard Screen reader Evergreen

Markup

html
<dialog class="b-command" data-shortcut>
  <div class="b-command-search">
    <svg>...</svg>
    <input type="search" placeholder="Type a command…">
    <kbd class="b-kbd">esc</kbd>
  </div>
  <ul class="b-command-list">
    <li><div class="b-command-group-label">Navigate</div></li>
    <li><a class="b-command-item" href="/dash"><span>Dashboard</span></a></li>
  </ul>
</dialog>

Behavior

When data-shortcut is present, ⌘K (or Ctrl+K) toggles the palette globally.

  • Type to filter
  • Arrow Up/Down to navigate, Home/End jump to the first and last item
  • Enter activates the highlighted item
  • Esc closes

The search input is exposed as role="combobox" controlling the list as a role="listbox", each .b-command-item becomes a role="option" with a generated id, and the active item is tracked via aria-activedescendant on the input. The <li> wrappers and .b-command-group-label headings are removed from the accessibility tree, because a listbox may only contain options — the headings remain as visual grouping.

API

ClassEffect
.b-commandUse on <dialog>
.b-command-searchSearch input row
.b-command-listItems list
.b-command-group-labelGroup separator
.b-command-itemSelectable item (anchor or button)
data-shortcut attributeEnables ⌘K binding
Edit this page