Skip to content

CommandPalette

CommandPalette

const commands: Command[] = [
{ id: 'goto-dashboard', label: 'Go to dashboard', group: 'Navigation', onAction: (close) => { router.push('/'); close(); } },
{ id: 'new-project', label: 'New project', group: 'Actions', keywords: ['create'], onAction: (close) => { openNewProject(); close(); } },
{ id: 'theme-toggle', label: 'Toggle theme', group: 'Settings', onAction: (close) => { toggleTheme(); close(); } },
];
<CommandPalette commands={commands} />

Press Cmd+K (Mac) or Ctrl+K (Windows/Linux) to open.

Install: @helixui/core

import { CommandPalette, type Command } from '@helixui/core'

status: beta · since: 0.2.0

Tags: cmd-k, search, actions, modal, productivity

Anatomy

┌─ overlay ────────────────────────────────┐
│ ┌── modal ───────────────────────────┐ │
│ │ > search │ │
│ │ ───────────── │ │
│ │ Section │ │
│ │ • action 1 ⌘K │ │
│ │ • action 2 │ │
│ │ Section │ │
│ │ • action 3 │ │
│ └────────────────────────────────────┘ │
└──────────────────────────────────────────┘

Layout

  • displayportal
  • widthfixed:560px
  • heightcontent
  • intrinsicSizecentered modal, max-h ~60vh
  • stackablefalse
  • fullBleedfalse

Visual

A centered modal with a top search input and a scrollable list of grouped commands beneath. Arrow keys navigate, Enter activates, ⌘K opens. Each item shows an optional icon, label, and shortcut hint.

Props

NameTypeDefaultDescription
commandsCommand[]Required. Each command has id, label, optional group, hint, keywords, icon, and an onAction(close) handler.
isOpenbooleanControlled visibility.
defaultOpenbooleanfalseUncontrolled initial visibility.
onOpenChange(open: boolean) => voidVisibility change handler.
shortcutstringMod+kGlobal keyboard shortcut to open. Mod = Cmd on Mac, Ctrl elsewhere.
placeholderstringType a command…Search input placeholder.
emptyMessageReactNodeNo matches.Shown when no commands match the query.

Tokens used

color.bg.surface.default, color.bg.action.neutral.default, color.bg.action.brand.subtle, color.border.default, color.text.primary, color.text.secondary, color.text.muted, color.text.action.brand, radius.lg, radius.md, radius.sm, space.2, space.3, space.4, space.6, font.family.sans, font.family.mono, font.size.xs, font.size.sm, font.size.md, font.weight.semibold, shadow.lg

Accessibility

Keyboard

KeyAction
Mod+kOpen palette globally.
ArrowDownNext command.
ArrowUpPrevious command.
EnterRun highlighted command.
EscapeClose palette.

Notes

  • The input is role="combobox"; the list is role="listbox"; items are role="option". The active item is announced via aria-activedescendant.

Composes with

ComponentRelationNote
MenualternativeMenu is anchored to a trigger; CommandPalette is global.
DialogalternativeDialog is for tasks; CommandPalette is for actions.
Popoversibling

Prompt examples

These are the AI prompt → JSX mappings used by the helixui prompt DSL and integrations like Cursor / Claude Code.

global cmd-k

“cmd+k command palette with two sections”

<CommandPalette
isOpen={open}
onOpenChange={setOpen}
commands={[
{ group: 'File', items: [{ id: 'new', label: 'New file', onPress: createFile }] },
{ group: 'Help', items: [{ id: 'docs', label: 'Open docs', onPress: openDocs }] },
]}
/>