Make your AI a shadcn expert

Shadcn Command

React command palette for search and quick actions. Built with TypeScript and Tailwind CSS for Next.js using Base UI — fuzzy filter, groups, and keyboard shortcuts.

The command menu is a searchable list of actions. Type to filter, arrow to a row, Enter to run it. Use it for a ⌘K palette, a file picker, or any list that is faster to search than to scan.

Scroll to load preview...

Looking for a neobrutalism version for shadcn?

Same command, thicker borders. The NeoBrutalism command is the kit if you want that look.

Usage

import {
  Command,
  CommandDialog,
  CommandEmpty,
  CommandGroup,
  CommandInput,
  CommandItem,
  CommandList,
  CommandSeparator,
  CommandShortcut,
} from "@/components/ui/command"
<Command className="max-w-sm rounded-lg border">
  <CommandInput placeholder="Type a command or search..." />
  <CommandList>
    <CommandEmpty>No results found.</CommandEmpty>
    <CommandGroup heading="Suggestions">
      <CommandItem>Calendar</CommandItem>
      <CommandItem>Search Emoji</CommandItem>
      <CommandItem>Calculator</CommandItem>
    </CommandGroup>
    <CommandSeparator />
    <CommandGroup heading="Settings">
      <CommandItem>Profile</CommandItem>
      <CommandItem>Billing</CommandItem>
      <CommandItem>Settings</CommandItem>
    </CommandGroup>
  </CommandList>
</Command>

shouldFilter is on by default — cmdk scores items as you type. Set value on each CommandItem so icons and shortcuts are not part of the query.

Composition

CommandInput
CommandEmpty
CommandItem
CommandItem
CommandSeparator

CommandDialog is that tree in a Dialog. CommandShortcut sits on a CommandItem.

Basic

A command menu in a dialog. Click the button.

Scroll to load preview...

Shortcuts

CommandShortcut is the hint on the right of the row. It does not bind the key.

Scroll to load preview...

Groups

heading on CommandGroup, CommandSeparator between sections, icons on the items.

Scroll to load preview...

Scrollable

CommandList already scrolls at 300px. Navigation, actions, view, account, tools.

Scroll to load preview...

RTL

Wrap with DirectionProvider and dir="rtl". The input, groups, and shortcuts follow the reading direction.

Scroll to load preview...

API

Prop

Type

CommandDialog

Prop

Type

CommandItem

Prop

Type

CommandGroup

Prop

Type

CommandInput takes value and onValueChange for the search string. CommandShortcut is a span.

Keyboard

KeyAction
TypeFilter the list
ArrowDown / ArrowUpNext / previous item
EnterRun the selected item
Ctrl+N / Ctrl+JNext item
Ctrl+P / Ctrl+KPrevious item
EscapeClose CommandDialog

Focus stays in CommandInput while they arrow. vimBindings is on unless you turn it off.

Notes

Shortcut is a label

CommandShortcut is a span. Bind ⌘K yourself — a keydown that sets CommandDialog open.

Set value on CommandItem when the row has an icon and a shortcut, or the filter string includes ⌘P.

With other components

Questions

Was this page helpful?

Sign in to leave feedback.