Command Palette

Searchable command dialog with ranking, optional async source, and recent ids.

Also known as: command menu, spotlight, quick actions

Installation

Install with the CLI, or copy the component source into your project.

Add command-palette (npm)

npx --yes -p @default-file/ui df-ui add command-palette

Default

Searchable command dialog with sections, glyphs, shortcuts, a disabled row, and recent ids first when the query is empty.

Recent ids sit first while the query is empty.

Ranking

rankTier sorts matching rows. Keywords expand what a query can hit. Type export to compare Export PNG with Open notes.

Open, then type export. Lower rankTier values sort first. Keywords still match.

Recent ids

When the query is empty, recentIds are listed first in host order, then the rest of the static list.

With an empty query, recentIds rise to the top in host order.

Async source

Optional source merges remote rows with static commands. Hold search keeps that request pending so the searching state stays visible.

Hold search keeps the source pending so the searching state stays on screen.

Empty

emptyContent replaces the catalogue empty copy when nothing matches.

No static commands. The empty slot is custom copy.

Search chrome

background is forwarded to the search field. footer replaces the default keyboard hints.

Custom search fill and footer hints.

Properties

Searchable command dialog over kit Dialog. Ranks static commands, optional async results, and recent ids, then runs the active command.

CommandPalette

PropTypeDefaultNotes
openboolean-Controlled open state.
defaultOpenbooleanfalseUncontrolled initial open state.
onOpenChange(open: boolean) => void-Called when open changes. Closing clears the query and async session.
commandsCommandItem[]-Static command list (required).
source(query: string) => Promise<CommandItem[]>-Optional async source. Debounced while open; merged with static commands.
recentIdsstring[][]Command ids promoted when the query is empty.
onRun(command: CommandItem) => void-Called after a command is chosen, before command.run().
placeholderstring-Search field placeholder. Defaults to the string catalogue.
backgroundstring-Search field fill, forwarded to SearchInput.
emptyContentReactNode-Empty status content when nothing matches. Defaults to the string catalogue.
footerReactNode-Footer content under the list. Defaults to short keyboard hints.
classNamestring-Additional styles on DialogContent.

CommandItem

PropTypeDefaultNotes
idstring-Stable id (required).
labelstring-Visible and searchable label (required).
sectionstring-Group heading. Falls back to the catalogue commands label.
keywordsstring[]-Extra strings included in ranking.
rankTiernumber0Ranking band for query results. Lower tiers sort before higher tiers.
glyphReactNode-Leading mark on the option row.
shortcutstring-Optional shortcut shown with Kbd.
disabledboolean-Non-runnable option.
run() => void-Action invoked when the command runs (required).

Keyboard and accessibility

Dialog (aria-label): DialogContent receives the catalogue command-palette accessible name. Search (combobox): Search input is a combobox with aria-controls and aria-activedescendant pointing at the active option. List (listbox): Results render as a listbox of options. Arrow keys move the active option; Enter runs it; Escape closes.