Skip to content

API reference

The full CommandPalette surface: props, the two-way open + query models, the select event, the imperative handle, and the slots. For the per-framework consumption code see the usage page.

Props

The full prop surface. The two model: true slices (open and query, the Two-way column) are two-way r-model bindings.

NameTypeDefaultTwo-way (model)RequiredDescription
openBooleanfalseWhether the palette overlay is shown (two-way r-model). Two-way bind it (r-model:open / v-model:open / bind:open / [(open)]); every close path (backdrop click, Escape, selecting an item when closeOnSelect, the imperative close()) writes open = false. As one of two model: true props the component does not generate an Angular ControlValueAccessor.
queryString''The current search text (two-way r-model). Two-way bind it to read or pre-seed the query; the component filters items by this string over each item label plus its keywords. Cleared to "" whenever the palette opens.
itemsArray[]The command list — [{ id, label, group?, keywords?, disabled? }]. label is the displayed (and filtered) text; id is a stable key passed back on select; optional group buckets items under a heading; optional keywords are extra strings the query also matches; an optional disabled flag styles an item and skips it for selection/navigation.
placeholderString"Type a command…"Placeholder text shown in the search input while the query is empty.
emptyTextString"No results."Text shown when the query matches no items. Override the whole empty state with the empty slot when you need richer markup.
closeOnSelectBooleantrueWhether choosing an item closes the palette. Defaults to true (the cmdk convention); set to false to keep the palette open after a selection — e.g. for a multi-action menu where the user runs several commands in a row.
ariaLabelString"Command palette"Accessible name for the dialog surface (aria-label on the role="dialog" panel). Override it to match the palette's purpose (e.g. "Search commands").
idBaseString"rozie-command-palette"Id base for the combobox and option elements — aria-activedescendant needs real ids. Option ids are derived as idBase + "-opt-" + i. Set a distinct value per instance when more than one palette shares a page. Named idBase (not id) to avoid shadowing HTMLElement.id on the Lit custom element.

Models (two-way state)

open and query are both model: true. Two-way bind each (r-model:open / v-model:open / bind:open / [(open)], and likewise for query). Because there are two models the component generates no Angular ControlValueAccessor — a palette is not a single form control.

Model (r-model:)ShapeDescription
openbooleanWhether the overlay is shown. Written back false on every close path (backdrop click, Escape, a closeOnSelect selection, or close()/toggle()).
querystringThe search text. Written back as the user types; cleared to "" whenever the palette opens.

Events

EventDescription
selectFired when the user chooses a command (click, or highlight + Enter). Payload { id, label, group } — the chosen item. open / query are two-way models, not events.

Imperative handle

Declared once via $expose; obtained through each framework's native ref mechanism.

MethodDescription
showOpen the palette (writes opentrue). Clears the query, resets the highlight, and focuses the search input. The open verb is shownot open — because an open() verb collides with the open model (both collapse onto React's generated open/setOpen state).
closeClose the palette (writes openfalse).
toggleFlip the open state.
focusMove DOM focus to the search input. Deliberately overrides the inherited HTMLElement.focus on the Lit custom element (accepted warn-only ROZ137).

Slots

SlotParamsDescription
option{ option, index, active, selected, disabled }Custom render for a single result row. Breaking change: renamed from item and realigned to the @rozie-ui/listbox option vocabulary (the palette now composes the listbox primitive). option is the command ({ id, label, group, keywords, disabled, _i }); index is its position; active is whether it is currently highlighted; selected whether it is the committed value; disabled whether it is non-selectable. Falls back to the label plus an optional group badge.
empty{ query }The no-results state; query is the current search string. Falls back to the emptyText prop.
footerA persistent footer bar below the list (e.g. keyboard hints). Rendered only when provided.

Pre-v1.0 — internal monorepo.