Skip to content

Command

A cmdk command menu and the command palette dialog.

Command is the list with its search field, for use inline. CommandDialog puts the same list in a dialog: the command palette. The item binds no shortcut; open the dialog from a button or from a key the product binds.

Inline

In a dialog

Nothing run yet

Command palette

Search for a command to run.

Checked items

Installation

npx shadcn@latest add @khaeli/command

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

npm packages
  • @keyline-icons/react ^2.2.0
  • cmdk ^1.1.1

Keyboard

Typing
Filters the rows as you type and highlights the first match. CommandEmpty shows when nothing matches. Focus stays in the search field throughout.
Arrow DownArrow Up
Move the highlight between rows. They skip a disabled row and stop at the first and the last row.
HomeEnd
Highlight the first and the last row.
Enter
Runs the highlighted row's onSelect.
Escape
In CommandDialog, closes the dialog and returns focus to what opened it. Inline it does nothing: the text stays in the field.

Accessible name

  • Command takes a label: it becomes a hidden label for the search field. Without it the field has only its placeholder.
  • CommandGroup is named by its heading. Rows are options in a list box that the field controls.
  • CommandDialog is named by title and described by description. Both are hidden from sight and default to English text, so set them.
  • data-checked on a CommandItem draws the check mark and is not announced. Set aria-checked beside it, as the third example does.
  • CommandShortcut is read as part of the row's name. It shows the keys and binds nothing.
  • CommandSeparator is a drawn line only: it is hidden from assistive technology, so the groups it divides are told apart by their headings.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/command.json