← Hub · Open the micro-demo

Command palette: discoverability, focus, and keyboard navigation

A command palette is a search box + a list of actions (commands). The hard part is not the UI — it’s the behavior.

Live demo: command-palette-demo.html (BEFORE/AFTER)

1) Discoverability: don’t hide it behind a secret shortcut

2) Opening behavior: focus predictably

3) Keyboard navigation: Arrow keys + Enter

4) Semantics: listbox + aria-activedescendant (one workable approach)

If the input keeps focus while you move an “active” highlight through options, connect them using aria-activedescendant:

<input aria-controls="cmdList" aria-activedescendant="cmd-settings">
<div id="cmdList" role="listbox">
  <div id="cmd-settings" role="option" aria-selected="true">Go to settings</div>
  ...
</div>

There are other valid patterns. Pick one and implement it consistently.

5) Don’t rely on color-only selection

6) Avoid shortcut conflicts and surprises

7) Keep announcements calm