Command Palette Preview

Use Command Palette Preview for a centered, searchable command interface. It is designed for keyboard-led navigation, with predictable filtering, arrow-key selection, and focused command groups.

Preview

Reduce motion:Off
Tune:Off
Inspect

Create

Navigate

↑ ↓ to navigate↵ to select

Installation

Basic usage

TypeScript
command-menu.tsx

Usage

API

PropertyTypeDefaultDescription
itemsCommandPaletteItem[]requiredCommands available in the palette.
openboolean—Controlled visibility state.
defaultOpenbooleanfalseInitial visibility for uncontrolled usage.
onOpenChange(open: boolean) => void—Called when the palette requests a visibility change.
placeholderstring"Search commands..."Placeholder shown in the command search field.
emptyMessagestring"No commands found."Copy shown when filtering returns no commands.
classNamestring—Additional CSS classes for the palette surface.

Accessibility

The palette uses a native modal dialog and a combobox with a labelled listbox. Opening focuses search and makes the surrounding page inert. Closing returns focus to the opener. Arrow keys follow the visible group order and keep the active result in view; Enter selects it and Escape dismisses the palette. IME composition does not activate commands.

Provide onSelect callbacks for command actions. The consumer owns the launcher and any global shortcut; the demo wires Command/Ctrl+K. Item shortcut values are display labels, not registered shortcuts. Filtering is retained when the palette is reopened.

Styling

CLI installation registers the shadow utilities automatically. For manual installation, install shadow-plugin and add @plugin "shadow-plugin"; to your Tailwind v4 stylesheet.

The palette intentionally uses an immediate open state because command interfaces are commonly keyboard-initiated. Style the surface with className while preserving the centered dialog hierarchy.

Was this page helpful?

Your response helps us improve component docs.