Overview
Modal search overlay for keyboard-first commands, destinations, and record jumpers.
CommandPalette intentionally uses a native modal <dialog> for top-layer,
backdrop, focus-trap, and aria-modal semantics. See the
native dialog contract.
For a non-modal single-value picker, use Combobox.
Usage
Grouped Results
Command items register with the palette by DOM node, so grouped results can use valid nested list markup without changing keyboard navigation. Use a presentational outer list item, an inner ul[role="group"] with an accessible name, and CommandItem children inside that inner list.
When to use
- Exposing a global keyboard-first launcher for power-user actions and navigation.
- Letting users search across heterogeneous results such as commands, pages, and records in one input.
- Picking a single value bound to a form field — use combobox instead.
- Showing a contextual action menu attached to a trigger — use dropdown instead.
Examples
Basic command palette
A minimal palette with three items opened by a button.
Grouped command palette
Command items grouped with named listbox sections.
Search, recent, and keyed actions
Cmd+K opens the palette. Three sections: filtered search results, recent items, and keyed actions separated by visual group headers.
Props
| Name | Type | Default | Description |
|---|---|---|---|
open bindable | boolean | false | Bindable open state. The component mutates open = false on Escape,
backdrop click, or any explicit close path, then fires onClose. |
placeholder | text | 'Search…' | Placeholder rendered inside the search input. |
label | text | 'Command palette' | Accessible name for the dialog, wired via aria-label. |
query bindable | text | '' | Bindable search query. Mutated by the input's oninput handler. Exposed to the items snippet so consumers can filter. Reset to an empty string each time the palette opens. |
onClose | () => void | Fired after any close path routed through the palette close lifecycle. | |
triggerRef | HTMLElement | null | null | Element to restore focus to on close. Falls back to captureFocus(). |
items required | snippet | Receives the current query so consumers can filter. | |
empty | snippet | Rendered when zero items are registered after filtering. | |
footer | snippet | Optional footer, e.g. for keybinding hints. Not part of the listbox. |