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
Installation
Basic usage
Usage
API
| Property | Type | Default | Description |
|---|---|---|---|
items | CommandPaletteItem[] | required | Commands available in the palette. |
open | boolean | — | Controlled visibility state. |
defaultOpen | boolean | false | Initial visibility for uncontrolled usage. |
onOpenChange | (open: boolean) => void | — | Called when the palette requests a visibility change. |
placeholder | string | "Search commands..." | Placeholder shown in the command search field. |
emptyMessage | string | "No commands found." | Copy shown when filtering returns no commands. |
className | string | — | 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.