Overview
Reference usage
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.
The headings follow Cinder’s group label pattern.
Bottom sheet, key hints and prefixes
- Sheet: below
sheetBelow(default640px;falsekeeps the centred panel) the palette opens as a bottom sheet: docked to the bottom edge with a grabber, a bordered search field with a Close button (closeLabel), and 44px rows. It rides above the on-screen keyboard, clears the bottom safe area, and its list scrolls inside the sheet. Under reduced motion it cross-fades instead of sliding. At wider widths it is the centred panel. - Key hints: give a
CommandItemkeys={['G', 'H']}and the row ends with "G then H", each key aKbd;keys={['C']}shows the single key. The hint is text in the row, so it is part of the option's accessible name. - Prefixes: filtering stays with the page, which receives the query in
items.parseCommandQuery(query, [{ prefix: '>', scope: 'actions' }, { prefix: '@', scope: 'agents' }])reads a leading prefix off the query and returns{ scope, term }, so typing>narrows to actions and@to agents. Say so in the footer snippet: "> actions", "@ agents", "Enter to open".
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.
Props
A backdrop click closes the palette only when the press starts and the click ends on the backdrop.
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
class |
string |
no | — | Class merged onto the palette panel. |
closeLabel |
string |
no | "Close" |
Accessible name and visible text of the Close button the sheet form shows beside the search field. |
escapeHint |
string | false |
no | "esc" |
The key hint at the end of the search field, drawn as a Kbd ("esc"), which says how to close the palette. false leaves it out. The bottom sheet shows a Close button instead and never the hint. |
label |
string |
no | — | Accessible name for the dialog, wired via aria-label. |
open |
boolean |
yes | — | Bindable open state. The component mutates open = false on Escape, backdrop click, or any explicit close path, then fires onClose. |
placeholder |
string |
no | — | Placeholder rendered inside the search input. |
query |
string |
no | — | 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. |
sheetBelow |
string | false |
no | "640px" |
Viewport width below which the palette opens as a bottom sheet instead of a centred panel: it docks to the bottom edge with a grabber, a search field with a Close button, 44px rows, and a height capped so the list scrolls inside it. It rides above the on-screen keyboard and respects the bottom safe area. A CSS length such as "640px", or false to keep the centred panel at every width. |
empty |
(opaque) |
no | — | Rendered when zero items are registered after filtering. Not expressible in JSON Schema; see the component types for the signature. |
footer |
(opaque) |
no | — | Optional footer, e.g. for keybinding hints. Not part of the listbox. Not expressible in JSON Schema; see the component types for the signature. |
items |
(opaque) |
yes | — | Receives the current query so consumers can filter. Not expressible in JSON Schema; see the component types for the signature. |
onClose |
(opaque) |
no | — | Fired after any close path routed through the palette close lifecycle. Not expressible in JSON Schema; see the component types for the signature. |
triggerRef |
(opaque) |
no | — | Element to restore focus to on close. Falls back to captureFocus(). Not expressible in JSON Schema; see the component types for the signature. |
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.
Key hints and prefixes
Navigation rows end with a key sequence read as "G then H"; a single key shows alone. Typing > narrows the list to actions and @ to agents. Below 640px the palette opens as a bottom sheet.
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. | |
sheetBelow | text | '640px' | Viewport width below which the palette opens as a bottom sheet instead of a centred panel: it
docks to the bottom edge with a grabber, a search field with a Close button, 44px rows, and a
height capped so the list scrolls inside it. It rides above the on-screen keyboard and
respects the bottom safe area. A CSS length such as "640px", or false to keep the centred
panel at every width. |
closeLabel | text | 'Close' | Accessible name and visible text of the Close button the sheet form shows beside the search field. |
escapeHint | text | 'esc' | The key hint at the end of the search field, drawn as a Kbd ("esc"), which says how to close
the palette. false leaves it out. The bottom sheet shows a Close button instead and never
the hint. |