Aliases
command menu, quick actions
components / commandpalette
Centered search-and-action surface for fast command execution, grouped results, and optional mod+k invocation.
Playground
Start here. Switch systems, interact with the shipped component, and let the rest of the page answer the why and how after the behavior clicks.
Cobalt
The crisp default DK action system: bright primary, roomy spacing, and a direct editorial rhythm.
Stage palette: closed
Overview
This section explains the intent of the component before the implementation details.
Aliases
command menu, quick actions
Explore the math
Decision guide
Use these notes to decide quickly whether this is the right DK component for the job.
Decision guide
Do
Do not
Usage
Prefer these situations when choosing this component.
Usage
These patterns are better served by a different component or a simpler surface.
Anti-patterns
Migration notes
Anatomy
The anatomy explains which pieces matter to the recipe and accessibility model.
command shell
surfaceCentered overlay surface that owns the filter input and result list.
command query
inputCombobox-style query field for filtering commands.
command option
itemSingle command row with optional section and shortcut metadata.
API
The docs contract distinguishes props, DOM events, and slots so integration behavior is explicit.
Props
| Name | Type | Default | Description |
|---|---|---|---|
open | boolean | false | Controlled open state. |
items | Array<{ id: string; label: string; section?: string; shortcut?: string; keywords?: string[]; disabled?: boolean }> | — | Command definitions available in the palette. |
query | string | '' | Controlled query string. |
placeholder | string | 'Search commands' | Query input placeholder. |
emptyTitle | string | — | Heading shown when filtering returns no results. |
emptyDescription | string | — | Supporting empty-state guidance. |
hotkey | 'mod+k' | false | false | Enables or disables the global mod+k launcher. |
onOpenChange | (detail: { open: boolean }) => void | — | Callback fired when the palette opens or closes. |
onQueryChange | (detail: { query: string }) => void | — | Callback fired when the query changes. |
onAction | (detail: { id: string }) => void | — | Callback fired when a command is executed. |
theme | ThemeContract | — | Overrides the compiled DK theme used to resolve tokens and recipes for this component. |
Events
| Name | Payload | Description |
|---|---|---|
openchange | { open: boolean } | Fires when an overlay-style component opens or closes through user interaction. |
querychange | { query: string } | Fires when the filter query changes. |
action | { id?: string; value?: string } | Fires when the component exposes a primary action and the user activates it. |
Slots
| Name | Description |
|---|---|
default | CommandPalette is data-driven in v1 and does not expose command item slots. |
Recipes
These notes summarize the intended recipe surface rather than exposing raw implementation detail first.
Variants
Sizes
States
Accessibility
This is the behavior the component promises to assistive tech and keyboard users today.
Semantics
Keyboard
Screen readers
Checklist
Implementation
This section shows the representative compiled slot variables that the runtime consumes for the selected design system.
Implementation notes
Implementation checklist
Examples
Each example is intentionally practical, grouped by starter, common pattern, and edge-case coverage.
Starter
1 example
starter
Starter: filtered command runnerA centered command surface with grouped actions.
Copy snippet
<CommandPalette open={isOpen} items={commands} onAction={(detail) => runCommand(detail.id)} />Common patterns
1 example
common
Common: global mod+k launcherEnable the built-in hotkey when the app has a strong command model.
Copy snippet
<CommandPalette hotkey="mod+k" items={commands} open={isOpen} onOpenChange={(detail) => isOpen = detail.open} />Edge cases
1 example
edge
Edge: externally controlled queryControl the query when search state also drives analytics or suggestions elsewhere in the app.
Copy snippet
<CommandPalette open={isOpen} query={query} onQueryChange={(detail) => query = detail.query} items={commands} />Verification
Proofs stay visible in the docs so the system shows what it can guarantee, not just what it can render.