Command Palette

Search for a command to run...

Command

Fast, composable, command menu for React.

Command Palette

Search for a command to run...

Installation

npm i cmdk

Usage

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandShortcut, } from "@/components/ui/command" export function CommandDemo() { return ( <Command className="rounded-lg border shadow-md"> <CommandInput placeholder="Type a command or search..." /> <CommandList> <CommandEmpty>No results found.</CommandEmpty> <CommandGroup heading="Suggestions"> <CommandItem> <CalendarIcon className="mr-2 h-4 w-4" /> <span>Calendar</span> </CommandItem> <CommandItem> <FolderIcon className="mr-2 h-4 w-4" /> <span>Documents</span> <CommandShortcut>⌘D</CommandShortcut> </CommandItem> <CommandItem> <SettingsIcon className="mr-2 h-4 w-4" /> <span>Settings</span> <CommandShortcut>⌘S</CommandShortcut> </CommandItem> </CommandGroup> </CommandList> </Command> ) }

Examples

Command Dialog

Press K to open the command menu

Props

ComponentPropsDescription
CommandCommandPrimitive.PropsThe root component for the command menu.
CommandDialogDialogProps
open?: boolean
onOpenChange?: (open: boolean) =\ void
A dialog wrapper for the command menu.
CommandInputCommandPrimitive.InputProps
placeholder?: string
The input field for the command menu.
CommandListCommandPrimitive.ListPropsThe container for command items.
CommandEmptyCommandPrimitive.EmptyPropsDisplayed when no results are found.
CommandGroupCommandPrimitive.GroupProps
heading?: string
A group of related command items.
CommandItemCommandPrimitive.ItemProps
onSelect?: (value: string) =\ void
An individual command item.
CommandSeparatorCommandPrimitive.SeparatorPropsA visual separator between command groups.
CommandShortcutHTMLAttributesDisplays a keyboard shortcut for a command.