Skip to content

Command Palette

A searchable command menu with grouped actions and keyboard navigation.

LIVE PREVIEWInteract with the component
Just React. No extra dependencies.

Copy the component and its CSS module into your project.

CSS Modules

Usage

Matches your current playground settings.

jsx
import CommandPalette from "./CommandPalette";
export default function Example() {
return (
<CommandPalette
items={[
{
"id": "new",
"label": "New canvas",
"description": "Start with a blank page",
"icon": "+",
"shortcut": "⌘ N",
"group": "Create"
},
{
"id": "browse",
"label": "Browse collection",
"description": "Find your next starting point",
"icon": "◇",
"shortcut": "⌘ B",
"group": "Create"
},
{
"id": "recent",
"label": "Recent projects",
"icon": "◷",
"shortcut": "⌘ R",
"group": "Navigate"
},
{
"id": "settings",
"label": "Preferences",
"icon": "⚙",
"shortcut": "⌘ ,",
"group": "Navigate"
}
]}
inline={true}
placeholder={"Where to next?"}
emptyLabel={"No matching commands"}
label={"Workspace commands"}
closeOnSelect={true}
accentColor={"#d9c6ef"}
/>
);
}

Using Command Palette

Supply commands through items and handle the chosen item with onSelect. Keep labels specific enough to distinguish similar actions in search.

Use open and onOpenChange for a dialog, or inline to embed the command list in a page. Set emptyLabel to explain when a search has no matches.

Props

NameTypeRequiredDefaultDescription
itemsobject[]No[]Array of { id, label, description?, icon?, shortcut?, group?, keywords?, disabled? }. Icons accept React nodes. Shortcut text is a display hint, not a registered global shortcut.
openbooleanNofalseControlled visibility when rendered as a modal dialog.
onOpenChangefunctionNoundefinedCalled with false when closing the modal is requested.
onSelectfunctionNoundefinedCalled with the chosen item. Disabled items cannot be selected.
inlinebooleanNofalseRender an embedded panel instead of a modal dialog.
placeholderstringNo"Search commands…"Search input placeholder and accessible label.
emptyLabelstringNo"No matching commands"Message when no commands match.
labelstringNo"Command menu"Accessible command menu label.
closeOnSelectbooleanNotrueRequest modal closure after selection. Inline panels remain visible.
accentColorstringNo"#d9c6ef"Selected command and search focus colour.
classNamestringNo""Additional CSS classes, merged with the component styles.
styleCSSPropertiesNoundefinedInline styles for caller-defined sizing and visual overrides.

Related components

Slide Drawer

Overlays

A full-height side panel slides over a softened backdrop with native modal focus.

Peek Popover

Overlays

A compact disclosure opens into a softly hinged floating surface.

Nebula Modal

Overlays

A controlled dialog with a soft coloured backdrop.

Lava Lamp

Backgrounds

Warm liquid forms merge and drift inside a softly lit glass lamp.