Command

React command palette built on cmdk with fuzzy search, groups, shortcuts, and a CommandDialog that wires Cmd+K and Ctrl+K. Works inline or as an overlay.

Command lists actions behind a search input; each CommandItem fires onSelect. CommandDialog is the same palette in an overlay and wires ⌘K itself.

When to use

Use Command to let power users jump to pages and actions by typing: opening a request by number, switching a service, or running an admin action. Mount CommandDialog once for a global palette, or use Command inline for a searchable action list.

For searching content rather than commands, use SearchBox.

Examples

Inline palette

⌘K dialog

Press ⌘K (or Ctrl+K) anywhere.

Custom shortcut (Arabic)

Props

Props declared by Command. Native attributes of the underlying element pass through.

<Command>

PropTypeDefaultDescription
childrenReactNode
asChildboolean
labelstringAccessible label for this command menu. Not shown visibly.
shouldFilterbooleanOptionally set to false to turn off the automatic filtering and sorting. If false, you must conditionally render valid items based on the search query yourself.
filterCommandFilterCustom filter function for whether each command menu item should matches the given search query. It should return a number between 0 and 1, with 1 being the best match and 0 being hidden entirely. By default, uses the command-score library.
defaultValuestring | (readonly string[] & string)Optional default item value when it is initially rendered.
valuestringOptional controlled state of the selected command menu item.
onValueChange(value: string) => voidEvent handler called when the selected item of the menu changes.
loopbooleanOptionally set to true to turn on looping around when using the arrow keys.
disablePointerSelectionbooleanOptionally set to true to disable selection via pointer events.
vimBindingsbooleanSet to false to disable ctrl+n/j/p/k shortcuts. Defaults to true.

<CommandInput>

PropTypeDefaultDescription
asChildboolean
valuestringOptional controlled state for the value of the search input.
onValueChange(search: string) => voidEvent handler called when the search value changes.

<CommandList>

PropTypeDefaultDescription
childrenReactNode
asChildboolean
labelstringAccessible label for this List of suggestions. Not shown visibly.

<CommandEmpty>

PropTypeDefaultDescription
childrenReactNode
asChildboolean

<CommandGroup>

PropTypeDefaultDescription
childrenReactNode
asChildboolean
headingReactNodeOptional heading to render for this group.
valuestringIf no heading is provided, you must provide a value that is unique for this group.
forceMountbooleanWhether this group is forcibly rendered regardless of filtering.

<CommandSeparator>

PropTypeDefaultDescription
asChildboolean
alwaysRenderbooleanWhether this separator should always be rendered. Useful if you disable automatic filtering.

<CommandItem>

PropTypeDefaultDescription
valuerequiredstringStable value for filtering + the onSelect payload. Required: cmdk would otherwise derive it from the rendered text, so a label / translation / icon change would silently change what onSelect receives.
startIconreact.ReactNodeLeading icon - mirrors Menubar / DropdownMenu item icons.
shortcutreact.ReactNodeRight-aligned keyboard hint, e.g. "⌘P" - mirrors Menubar / DropdownMenu.
onSelect(value: string) => voidFires when the item is chosen (click / Enter). Receives the item's value (cmdk defaults it to the text content when value is omitted). Action-oriented: items run a command and don't track selection. Inside CommandDialog the consumer closes the dialog here, e.g. onSelect={() => { setOpen(false); run(); }}.
childrenReactNode
asChildboolean
disabledbooleanWhether this item is currently disabled.
keywordsstring[]Optional keywords to match against when filtering.
forceMountbooleanWhether this item is forcibly rendered regardless of filtering.

<CommandDialog>

PropTypeDefaultDescription
openbooleanControlled open state.
defaultOpenbooleanInitial open state when uncontrolled.
onOpenChange(open: boolean) => void
shortcutstring | falseKey for the built-in document shortcut (with Cmd on macOS / Ctrl elsewhere). Defaults to 'k' (⌘K / Ctrl+K). Pass false to bind no listener and wire your own. The modifier is fixed; only the key is configurable.
labelreact.ReactNodeAccessible name → visually-hidden DialogTitle. Defaults to "Command palette".
descriptionreact.ReactNodeOptional visually-hidden DialogDescription.
classNamestring
childrenrequiredreact.ReactNodeCommandInput + CommandList + groups / items.
shouldFilterbooleanOptionally set to false to turn off the automatic filtering and sorting. If false, you must conditionally render valid items based on the search query yourself.
filterCommandFilterCustom filter function for whether each command menu item should matches the given search query. It should return a number between 0 and 1, with 1 being the best match and 0 being hidden entirely. By default, uses the command-score library.
loopbooleanOptionally set to true to turn on looping around when using the arrow keys.

Accessibility

The input is a role="combobox" tied to a role="listbox" of results, so arrow keys move through matches, Enter runs the highlighted item, and Escape closes. Give the input an aria-label.

The dialog variant traps focus and returns it on close. Shortcuts shown next to items are hints; every item also works by mouse and keyboard.