<buttonclass="btn btn--outline-secondary command-palette-trigger"type="button"data-command-openaria-haspopup="dialog"aria-keyshortcuts="Control+K Meta+K"><svgclass="btn__icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"fill="none"stroke="currentColor"stroke-width="2"stroke-linecap="round"stroke-linejoin="round"aria-hidden="true"focusable="false"><circlecx="11"cy="11"r="8"/><pathd="m21 21-4.3-4.3"/></svg>
Search commands…
<kbd>Ctrl K</kbd></button><dialogclass="command-palette"aria-label="Command palette"data-command-palette><divclass="command-palette__search"><svgxmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"fill="none"stroke="currentColor"stroke-width="2"stroke-linecap="round"stroke-linejoin="round"aria-hidden="true"focusable="false"><circlecx="11"cy="11"r="8"/><pathd="m21 21-4.3-4.3"/></svg><inputclass="command-palette__input"type="text"role="combobox"aria-expanded="true"aria-controls="command-palette-listbox"aria-autocomplete="list"aria-label="Search commands"placeholder="Type a command or search…"autocomplete="off"data-command-input><kbd>Esc</kbd></div><divclass="command-palette__results"id="command-palette-listbox"role="listbox"aria-label="Commands"><pclass="command-palette__group"id="command-group-navigation"aria-hidden="true">Navigation</p><ulclass="command-palette__list"role="group"aria-labelledby="command-group-navigation"><liclass="command-palette__option"role="option"id="command-go-to-dashboard"aria-selected="false"data-command>Go to dashboard<spanclass="command-palette__keys"><kbd>G</kbd><kbd>D</kbd></span></li><liclass="command-palette__option"role="option"id="command-go-to-projects"aria-selected="false"data-command>Go to projects<spanclass="command-palette__keys"><kbd>G</kbd><kbd>P</kbd></span></li><liclass="command-palette__option"role="option"id="command-go-to-settings"aria-selected="false"data-command>Go to settings<spanclass="command-palette__keys"><kbd>G</kbd><kbd>S</kbd></span></li></ul><pclass="command-palette__group"id="command-group-actions"aria-hidden="true">Actions</p><ulclass="command-palette__list"role="group"aria-labelledby="command-group-actions"><liclass="command-palette__option"role="option"id="command-create-a-new-page"aria-selected="false"data-command>Create a new page<spanclass="command-palette__keys"><kbd>N</kbd></span></li><liclass="command-palette__option"role="option"id="command-invite-a-teammate"aria-selected="false"data-command>Invite a teammate<spanclass="command-palette__keys"><kbd>I</kbd></span></li><liclass="command-palette__option"role="option"id="command-switch-design-style"aria-selected="false"data-command>Switch design style<spanclass="command-palette__keys"><kbd>S</kbd></span></li></ul><pclass="command-palette__group"id="command-group-help"aria-hidden="true">Help</p><ulclass="command-palette__list"role="group"aria-labelledby="command-group-help"><liclass="command-palette__option"role="option"id="command-read-the-documentation"aria-selected="false"data-command>Read the documentation<spanclass="command-palette__keys"><kbd>?</kbd></span></li><liclass="command-palette__option"role="option"id="command-contact-support"aria-selected="false"data-command>Contact support<spanclass="command-palette__keys"></span></li></ul></div><pclass="command-palette__empty"hiddendata-command-empty>No results.</p><pclass="sr-only"aria-live="polite"data-command-status></p></dialog>
A keyboard-first command palette (like Ctrl + K in many apps) to search and run actions.
Technical Details
It is a modal dialog with a combobox input and a grouped listbox (the WAI-ARIA combobox pattern): the focus stays in the input, and aria-activedescendant points to the highlighted option.
Ctrl/⌘ + K opens it from anywhere; ↑/↓ move, Home/End jump, Enter runs the command, Esc closes it, and the focus returns to the trigger.
Typing filters the options (groups without results hide), and a polite live region announces the number of results.
The trigger advertises the shortcut with aria-keyshortcuts.
Replace the data-command items with your own actions: the script dispatches a command event on the dialog with the chosen option's text.
Documentation
Learn about Spruce CSS through our extensive documentation.