CommandPalette
Search grouped commands and navigation targets from an inline surface.
Use CommandPalette for searchable commands or navigation targets. The application decides when to open it and registers any global shortcut.
Basic usage#
Playground#
Anatomy#
Group labels and items may be flattened into sibling rows when virtualized. Trailing descriptions render inside itemLabel.
Usage#
Groups, filtering, and selection#
Pass groups and items from application state. The palette filters the supplied collection and invokes item selection callbacks; fetching commands, routing, and global keyboard shortcuts are application-owned.
Custom states and navigation#
Use the custom item renderer for a changed item layout, and provide loading or empty content when those states need explanation. Sub-navigation should represent a short, deliberate branch of commands rather than a complete application shell.
Keyboard interaction#
| Key | Description |
|---|---|
| ↓ | Moves to the next available command. |
| ↑ | Moves to the previous available command. |
| ↵ | Activates the current command. |
| Esc | Clears the current query or requests close according to current state. |
| ↖ / ↘ | Moves to the first or last available command. |
Examples#
Custom item rendering#
Custom empty state#
Loading#
Sub-navigation#
Attributes#
data-disabledSlot: command-palette-itemDescription: Present when the component, slot, or item is disabled.data-highlightedSlot: command-palette-item, command-palette-item-leading, command-palette-item-description, command-palette-item-trailingDescription: Present when the item is highlighted by pointer or keyboard navigation.data-loadingSlot: command-palette-input-leadingDescription: Present when the component or async operation is loading.Props#
Renders a <div> element by default.