All specs
Interactive · command-palette

Command Palette

Fuzzy command search with grouped results and keyboard shortcuts.

Anatomy

▸ buil█  3/12

  Tasks
  ▸ Build project           [Ctrl+B]
  · Build for production
  · Build Docker image

type to filter  ↑↓ navigate  ↵ run  esc cancel

Usage

const cmd = await commandPalette({
  commands: [
    { value: 'build',    label: 'Build project',  group: 'Tasks', shortcut: 'Ctrl+B' },
    { value: 'test',     label: 'Run tests',      group: 'Tasks', shortcut: 'Ctrl+T' },
    { value: 'deploy',   label: 'Deploy to prod',  group: 'Deploy' },
    { value: 'settings', label: 'Open settings',   group: 'Config' },
  ],
  placeholder: 'Type a command…',
})

if (cmd === 'build') { /* ... */ }

Options

KeyTypeDefaultDescription
commandsCommand[]Command list
placeholderstring?Shown when query empty
limitnumber?10Max visible commands
filter(query, cmd) => boolfuzzy on label+group+descCustom filter

### Command type

type Command<T extends string> = {
  value: T
  label: string
  group?: string        // visual grouping header
  description?: string  // shown after label when focused
  shortcut?: string     // keyboard shortcut hint
}

Keyboard

KeyAction
charsAppend to query
BackspaceDelete character
Ctrl+UClear query
Move selection
Run selected command
escCancel → null
Feature`search``commandPalette`
GroupingNoYes (by group)
ShortcutsNoYes (shortcut hint)
Use caseData filteringAction dispatch

Out of scope

Inline command execution

Recent/frequent command ranking

Nested subcommands