Skip to content

Command palette

Opens a search dialog to find and run commands.

command-palette-basic-demo.tsx

Installation

The CLI adds the files, packages, theme variables, and Tailwind plugin that this component uses. Before you run it, set up your project.

Composition

  • CommandPalette
    • CommandPaletteSection
      • CommandPaletteItemRepeats

Sections, icons, and shortcuts

When an item has an icon, set textValue so search can find it.

command-palette-demo.tsx

API reference

vip/ui adds or changes the props below. For all other props, see React Aria Menu (opens in a new tab).

CommandPalette

isOpen: booleanRequired
Controls the dialog's visibility.
onOpenChange: (open: boolean) => voidRequired
Receives requests to open or close the dialog.
shortcut: boolean = true
Ctrl+K or Command+K opens and closes the palette. Disable it when another palette owns that shortcut.
title: string = "Commands"
Accessible dialog name.
placeholder: string = "Search commands"
Search input placeholder and label.
emptyMessage: string = "No matching commands."
Text shown when search has no results.

CommandPaletteSection

title: stringRequired
Heading for a group of items. A section with no matching items is hidden.

CommandPaletteItem

textValue: string
Text that search matches. Without it, search uses the text children. Set it when the item has an icon or other elements.
shortcut: string
A key hint at the end of the item. Screen readers hear it as the item description. It does not add a key handler.
variant: "default" | "destructive" = "default"
Destructive colors the item for actions you cannot undo.