Command

A searchable command palette, with a nested stack for layered lists.

Default

CommandDialog centers a searchable list over an overlay. Group items with CommandGroup headings, split sections with CommandSeparator and show shortcuts with CommandShortcut.

Keyboard shortcut

Open the menu from a global shortcut and show the same keys on the trigger. This example uses ⌘J because the docs search owns ⌘K.

Entity items

Pass layout="entity" for 60px rows with a 40px avatar, a title and a description, such as agents or contacts.

Close button

Pass showCloseButton when the menu is a picker rather than a quick launcher. Escape and a click outside still close it.

Nested

Render a CommandDialog inside another and open it from an item's nestedSelect. The front card presses in on pointer down, then settles into a stack behind the new layer. Escape goes back one layer.

Best practices

When to use

  • Use for a keyboard-first launcher or picker across many destinations and actions: go to a page, switch agent, assign a number.
  • Use Combobox or Select for choosing a value inside a form, and Dropdown Menu for a few actions on one object.

Behavior

  • Open CommandDialog with open/onOpenChange from a trigger and a global shortcut, and show the same keys on the trigger (Button keys).
  • Close the dialog in each item's onSelect. Use nestedSelect to push a nested CommandDialog; Escape goes back one layer.
  • Pass showCloseButton when the menu is a picker rather than a quick launcher.

Content

  • Pass a sentence-case title and description to CommandDialog; they are visually hidden but announced.
  • Group items under short CommandGroup headings, lead compact items with a 20px icon, and use layout="entity" for people or agents with a second line.
  • Always include CommandEmpty with a specific message (“No agents found.”) and keep the placeholder action-oriented (“Search agents…”).

Accessibility

  • Keep CommandFooter's navigate and select hints, or replace them with equally clear text; every item must be reachable with the arrow keys.