Command palette
Motion's fuzzy-filtered Cmd+K launcher choreography on Base UI's Dialog primitive, with a sliding selection highlight.
API reference
Components
<CommandPalette />
open?
Controlled open state. Omit for uncontrolled state.
defaultOpen?
Initial open state when uncontrolled. Defaults to false.
onOpenChange?
Called whenever Base UI requests an open-state change.
items
The commands the palette filters and lists.
groupOrder?
The order group headers render in; defaults to the items' own first-seen group order. Groups left empty by the current query are dropped.
maxListHeight?
Tallest the scrollable result list is allowed to grow before it scrolls internally - how much of the command set is visible at once.
triggerLabel?
The collapsed trigger bar's placeholder text.
triggerShortcut?
The trigger's trailing shortcut badge glyphs.
inputPlaceholder?
The open dialog input's placeholder.
inputAriaLabel?
The open dialog input's accessible label.
dialogLabel?
The dialog's accessible label.
footerHints?
The footer-strip hints. Defaults to navigate / select / close.
renderEmpty?
Renders the no-results message; receives the trimmed query.
onSelect?
Called with the chosen item when a row is selected (click or Enter). The palette closes itself afterwards; wire navigation here.
Hooks
useCommandK
Headless open-state engine for a command palette. Manages the open flag and installs a single window-level Cmd/Ctrl+K listener that toggles it from anywhere on the page (not only while a trigger holds focus - the defining Cmd+K affordance). CommandPalette uses this internally; call it yourself to drive a custom trigger or your own palette surface.
useCommandK(options: UseCommandKOptions): UseCommandKResultdefaultOpen?
Whether the palette starts open. Defaults to false.
open?
Controlled open state. Omit for uncontrolled state.
onOpenChange?
Called whenever the open state changes (opened or closed).
Returns
open
Whether the palette is open.
setOpen
Set the open state directly.
openPalette
Open the palette.
closePalette
Close the palette.
toggle
Toggle the palette - what the global Cmd/Ctrl+K shortcut fires.
Functions
fuzzyMatch
Subsequence fuzzy match: every character of query must appear, in order, somewhere in target - a genuinely fuzzy filter rather than a plain substring test, so "fnl" still surfaces "Funnels". Both arguments are matched as-is (lower-case them yourself, as commandMatches does).
fuzzyMatch(query: string, target: string): booleancommandMatches
Whether a command survives the query: its lower-cased label, or any of its keywords, fuzzy-matches the trimmed lower-cased query. An empty query matches everything.
commandMatches(command: CommandPaletteItem, query: string): booleanid
label
hint?
group?
icon?
shortcut?
keywords?
filterCommandGroups
Filters items by query and buckets the survivors into groups, in groupOrder (falling back to the items' own first-seen group order), dropping any group left empty. This is exactly what CommandPalette shows; call it directly if you filter a remote command source yourself.
filterCommandGroups(items: T[], groupOrder: string[] | undefined, query: string): CommandGroupView<T>[]nextCommandIndex
Wraps listbox keyboard navigation while keeping an empty result set at zero.
nextCommandIndex(currentIndex: number, resultCount: number, direction: "next" | "previous"): numberFeatured in
See the command palette composed into full sections.

