Overview
Modal search overlay for keyboard-first commands, destinations, and record jumpers.
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 | Required | Bindable | Description |
|---|---|---|---|---|---|
open | boolean | false | bind | 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 | text | '' | bind | 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 | snippet | req | 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. |