Skip to content
IndexRequest a UIAboutContact

Command Palette

Press Ctrl or Cmd + K (or the button) to open a searchable list of actions, move with arrows and run with Enter.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Design a command palette overlay opened with Ctrl or Cmd + K. A centred 340 pixel panel with a search input ("Type a command…") and a list of six actions with small shortcut hints on the right: New file, Open settings, Toggle theme, Share, Copy link, Sign out. Typing filters the list and bolds the matched letters, arrow keys move the selection, Enter runs it and shows "Ran: New file" in the page behind, Escape closes. Use role combobox with aria-activedescendant for the input and role listbox for the list. Light panel, 14 pixel radius, soft shadow, backdrop blur, 150 millisecond fade-drop with prefers-reduced-motion fallback. Plain HTML, CSS and JavaScript.

About this pattern

Definition

A command palette is a keyboard-first overlay with a search field and a filtered list of actions. It lets people reach any command without hunting through menus.

Purpose & UX principles

  • Open with a global shortcut; show recent or common commands before typing.
  • Filter as you type, highlight the match and keep the first result selected so Enter works immediately.
  • Show shortcuts next to commands, confirm the action and close the palette.

Interaction states

  • Closed, open with all commands, filtered, empty ("No results"), and a confirmation after running a command.

Motion specification

  • Panel fades and drops 8px over 150ms; selection highlight moves instantly.
  • Reduced motion: fade only.

Responsive behaviour

  • On phones open it as a full-width sheet near the top; keep rows at least 44px tall.
  • Limit visible rows to about seven and scroll the rest.

Code

HTML
<div class="bx"><button id="op" type="button">Open palette <kbd>⌘K</kbd></button><p class="res" id="res" aria-live="polite">Press Ctrl or ⌘ + K.</p>
<div class="bk" id="bk" hidden><div class="pl"><input id="q" role="combobox" aria-expanded="true" aria-controls="ls" aria-activedescendant="" placeholder="Type a command…" autocomplete="off"><ul id="ls" role="listbox"></ul></div></div></div>

Related patterns

Search Input

↗
Search InputInputs & Forms

Modal Dialog

↗
Modal DialogOverlays & Dialogs

Dropdown Menu

↗
Dropdown MenuOverlays & Dialogs