Command

A searchable list of actions, opened with a shortcut.

General

Type to filter, use the arrow keys to move and Enter to run the action.

With Shortcut

Open it with Cmd+K, or Ctrl+K on Windows and Linux, using useKeyboard.

App command palette

List the actions people reach for most, with a short hint of the shortcut on the right.

APIs

Command.Props

AttributeDescriptionTypeAccepted valuesDefault
visibleshow the paletteboolean--
onClosecalled on Esc, backdrop or selection() => void--
itemsactions to listCommandItem[]--
placeholderplaceholder of the search fieldstring-Type a command or search
emptyTextshown when nothing matchesstring-No results. Try another word.

CommandItem

interface CommandItem {
  value: string
  label: string
  icon?: React.ReactNode
  hint?: React.ReactNode
  onSelect?: () => void
}

Accessibility

  • • The palette opens in a Modal named Command, so focus goes into it and Escape closes it.
  • • The field is a combobox over a listbox of options. It points to the highlighted option with aria-activedescendant, so a screen reader announces each item as the arrows move, and the option has aria-selected. Arrow Down and Arrow Up move through the items and wrap around, and Enter runs the highlighted one.
Edit this page on GitHub