Command

Command

A command palette that filters actions as you type, built on cmdk. Use it inline or in CommandDialog for a ⌘K-style overlay.

Playground

placeholder
shortcuts
<Command className="max-w-md rounded-xl shadow-5xs">
  <CommandInput placeholder="Type a command or search..." />
  <CommandList>
    <CommandEmpty>No results found.</CommandEmpty>
    <CommandGroup heading="Suggestions">
      <CommandItem>
        <Calendar />
        Calendar
      </CommandItem>
      <CommandItem>
        <Smile />
        Search Emoji
      </CommandItem>
    </CommandGroup>
    <CommandGroup heading="Settings">
      <CommandItem>
        <User />
        Profile
        <CommandShortcut>⌘P</CommandShortcut>
      </CommandItem>
      <CommandItem>
        <Settings />
        Settings
        <CommandShortcut>⌘S</CommandShortcut>
      </CommandItem>
    </CommandGroup>
  </CommandList>
</Command>

Preview

Command wires the CommandInput to the CommandList below it – typing filters items automatically, and CommandEmpty shows when nothing matches.

<Command className="max-w-md rounded-xl shadow-5xs">
  <CommandInput placeholder="Type a command or search..." />
  <CommandList>
    <CommandEmpty>No results found.</CommandEmpty>
    <CommandGroup heading="Suggestions">
      <CommandItem>
        <Calendar />
        Calendar
      </CommandItem>
      <CommandItem>
        <Smile />
        Search Emoji
      </CommandItem>
      <CommandItem>
        <Calculator />
        Calculator
      </CommandItem>
    </CommandGroup>
  </CommandList>
</Command>

Installation

npx shadcn@latest add https://espresso-base-ui.vercel.app/r/command.json

Usage

import {
  Command,
  CommandDialog,
  CommandEmpty,
  CommandGroup,
  CommandInput,
  CommandItem,
  CommandList,
  CommandShortcut,
} from "@/components/ui/command"
<Command>
  <CommandInput placeholder="Search..." />
  <CommandList>
    <CommandEmpty>No results found.</CommandEmpty>
    <CommandGroup heading="Suggestions">
      <CommandItem>Calendar</CommandItem>
      <CommandItem>Calculator</CommandItem>
    </CommandGroup>
  </CommandList>
</Command>

Groups and shortcuts

Give each CommandGroup a heading and right-align key hints with CommandShortcut.

<Command className="max-w-md rounded-xl shadow-5xs">
  <CommandInput placeholder="Type a command or search..." />
  <CommandList>
    <CommandEmpty>No results found.</CommandEmpty>
    <CommandGroup heading="Suggestions">
      <CommandItem>
        <Calendar />
        Calendar
      </CommandItem>
    </CommandGroup>
    <CommandGroup heading="Settings">
      <CommandItem>
        <User />
        Profile
        <CommandShortcut>⌘P</CommandShortcut>
      </CommandItem>
      <CommandItem>
        <Settings />
        Settings
        <CommandShortcut>⌘S</CommandShortcut>
      </CommandItem>
    </CommandGroup>
  </CommandList>
</Command>

Disabled items

disabled on a CommandItem dims it and removes it from pointer and keyboard selection.

<CommandGroup heading="Unavailable">
  <CommandItem disabled>New Team (Pro plan)</CommandItem>
  <CommandItem disabled>Invite Members (Pro plan)</CommandItem>
</CommandGroup>

Command dialog

CommandDialog wraps the palette in a Dialog positioned at the upper third of the screen – control it with open / onOpenChange and bind it to a ⌘K keydown listener for a global palette.

Command Palette

Search for a command to run...

const [open, setOpen] = React.useState(false)

<Button variant="outline" onClick={() => setOpen(true)}>
  Open command palette
</Button>

<CommandDialog open={open} onOpenChange={setOpen}>
  <Command>
    <CommandInput placeholder="Type a command or search..." />
    <CommandList>
      <CommandEmpty>No results found.</CommandEmpty>
      <CommandGroup heading="Suggestions">
        <CommandItem onSelect={() => setOpen(false)}>
          <Calendar />
          Calendar
        </CommandItem>
      </CommandGroup>
    </CommandList>
  </Command>
</CommandDialog>

API reference

Command is the cmdk root and accepts all cmdk props – value, onValueChange, shouldFilter, filter and loop. Every other part takes className plus its cmdk primitive props.

CommandDialog

PropTypeDefaultDescription
titlestring"Command Palette"Screen-reader-only dialog title (visually hidden DialogTitle).
descriptionstring"Search for a command to run..."Screen-reader-only dialog description.
showCloseButtonbooleanfalseShow the dialog's top-right close button inside the palette.
open / onOpenChangeboolean / (open) => void–Controlled open state, forwarded to the underlying Dialog.

CommandItem

PropTypeDefaultDescription
valuestring–Value used for filtering and selection; defaults to the item's text content.
onSelect(value: string) => void–Called when the item is picked via click or Enter.
disabledbooleanfalseDims the item and skips it during navigation.
ComponentDescription
CommandFiltering root (data-slot="command") on a popover surface; owns the search state.
CommandInputSearch field (data-slot="command-input") rendered inside an InputGroup with a trailing search icon; the wrapper carries data-slot="command-input-wrapper".
CommandListScrollable results container (data-slot="command-list") with a max height.
CommandEmptyPlaceholder (data-slot="command-empty") shown when no item matches the query.
CommandGroupItem group (data-slot="command-group") with an optional heading styled via cmdk-group-heading.
CommandItemSelectable row (data-slot="command-item") with icon support and a trailing check icon when data-checked is set.
CommandShortcutRight-aligned keyboard hint span (data-slot="command-shortcut").
CommandDialogDialog wrapper that positions the palette at the top third of the viewport with zero padding.

Accessibility & styling hooks

cmdk renders the list with role="listbox", keeps aria-selected on the highlighted option, and supports full keyboard navigation (arrows, Home/End, Enter). In CommandDialog, the underlying Dialog adds focus trapping and Escape-to-close, with a visually hidden title and description for screen readers. Every part exposes a data-slot attribute, and items reflect cmdk state as data-selected and data-disabled – target these from CSS for app-level overrides.

Search documentation

Search the component docs