02UI

Command palette

A command palette is a searchable overlay for jumping to pages and running actions without hunting through menus. Linear, Notion, and Gmail all use one because power users live on the keyboard.

OverlaysBuild difficulty: Hard<div role="dialog" aria-modal="true">

Also called Command menu, Quick switcher, Spotlight bar, Omni bar.

or press ⌘K

Command Palette

Search for a command to run...

Press ⌘K or click Open commands, then type to filter. Arrow keys move through the list, Enter runs the highlighted row.

For designers

A command palette turns every destination and action in an app into one searchable list. Press a shortcut, type two letters, pick a row: that is faster than clicking through three menus for someone who already knows what they want. Linear, Notion, and VS Code all ship one for this reason.

The cost is learning curve. Casual users will never open it unless the shortcut is visible somewhere in the interface, and the list has to stay complete. A palette missing a destination people reach for every day gets ignored after one try. Budget time to keep the index current as the product grows, because a stale palette is worse than no palette at all.

Stripe's dashboard search bar and Gmail's search box sit in the same family: one field, every destination reachable. The difference is scope. A palette lists what your product already defines. Search scans what it has stored.

When to use a command palette

Use a command palette when

  • The product has more than about ten destinations or actions people reach for repeatedly
  • Power users already ask for keyboard shortcuts and you want one place to list them all
  • Someone knows the name of what they want and would rather type two letters than click three menus

Reach for something else when

Variants

Navigation

  • Go to Invoices
  • Go to Customers
  • Open Settings

Actions

  • Create invoice
  • Toggle dark mode

Recent

  • Create invoice
  • Go to Invoices
  • Open Settings

Navigation rows jump to pages, action rows run something, and a Recent group saves repeat typing.

Navigation. Go to pages and sections: Invoices, Settings, a specific project. The rows people reach for most often.

Actions. Create invoice, archive project, toggle dark mode. Each row runs something and closes the palette.

With recents. A Recent group above the search results saves the five commands someone used last, so repeat work needs no typing at all.

How to build a command palette

Mark up the overlay as a dialog with a labelled search field and a listbox of options. The WAI-ARIA Authoring Practices describe the combobox-in-dialog pattern that most implementations follow.

<div role="dialog" aria-modal="true" aria-labelledby="cmd-title">
  <h2 id="cmd-title" class="sr-only">Commands</h2>
  <input type="search" role="combobox" aria-controls="cmd-list"
         aria-expanded="true" placeholder="Type a command…">
  <ul id="cmd-list" role="listbox">
    <li role="option">Go to Invoices</li>
    <li role="option">Create invoice</li>
    <li role="option">Open settings</li>
  </ul>
</div>

Trap focus inside the dialog while it is open. Arrow keys move through the list, Enter runs the highlighted row, Escape closes without running anything. Register the keyboard shortcut at the document level and prevent the browser from stealing it. The search field should receive focus on open, not the first result, so someone can start typing immediately. Fuzzy matching helps, but rank exact prefix matches above partial ones so Invoices beats Invoice settings when someone types inv.

Edge cases

Empty search results. Show a clear No results line rather than a blank panel.

Slow commands. If a row kicks off work that takes seconds, close the palette and show progress elsewhere. Leaving the dialog open while something runs behind it feels stuck.

Duplicate shortcuts. Two rows sharing the same shortcut will confuse people. Audit the list before launch and resolve conflicts. If two commands must share a shortcut, pick different contexts rather than duplicating the hint on both rows.

Common questions

What keyboard shortcut should open a command palette?
⌘K on Mac and Ctrl+K on Windows is the convention Linear and Notion established. Register it at the document level and prevent the browser from stealing it. Show the shortcut somewhere visible so people who do not know it can learn it.
Command palette or search?
Search scans content you do not already know: files, messages, records. A command palette lists destinations and actions you have already defined. If someone is hunting through a database, use search. If they know the page name and want to jump there, use a palette.
Should a command palette trap focus?
Yes. It is a modal dialog. Tab cycles inside the overlay, Escape closes without running anything, and focus returns to the trigger on close. WCAG 2.4.3 applies: focus order should follow a sensible path through the search field and the results.
How should commands be grouped?
Navigation in one group, actions in another, and optionally a Recent group at the top for the five commands someone ran last. More than three groups and the list becomes harder to scan than a flat list with good search.
What happens when search returns nothing?
Show a clear No results line in the panel. A blank list reads as broken. If the missing command is a common request, that is a signal to add it.
Should every command show a keyboard shortcut?
Only the ones that actually have one. Trailing hints formatted the way the operating system shows its own, like ⌘N, not a new invented style.

Last reviewed 27 AUG 2026