Component guideEditable source

Command

A searchable command list, optionally presented inside a dialog.

Original component docs
On this page4 sectionsBack to top

Use Command for searchable actions or destinations. CommandDialog combines the list with a dialog, while Command can be embedded in a popover or panel. Shortcut annotations do not register keyboard handlers.

Live preview
Loading preview...

#Installation

Complete the base setup. For manual installation:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/command.json

#Usage

"use client";
import { useState } from "react";
import {
  Command,
  CommandInput,
  CommandList,
  CommandEmpty,
  CommandGroup,
  CommandItem,
} from "@/components/ui/command";

export default function WorkspaceCommands() {
  const [message, setMessage] = useState("No command selected.");
  return (
    <div className="grid gap-3">
      <Command className="max-w-sm rounded-base border-2 border-border">
        <CommandInput placeholder="Find an action…" aria-label="Find an action" />
        <CommandList>
          <CommandEmpty>No matching command.</CommandEmpty>
          <CommandGroup heading="Workspace">
            <CommandItem value="new-draft" onSelect={() => setMessage("Created a local draft.")}>
              New draft
            </CommandItem>
            <CommandItem disabled>Export workspace</CommandItem>
          </CommandGroup>
        </CommandList>
      </Command>
      <p role="status">{message}</p>
    </div>
  );
}

#API reference

Prop / partPurposeDefault
Command.shouldFilterBuilt-in client filteringtrue
CommandInput.value / onValueChangeControlled queryUncontrolled
CommandItem.value / keywordsSearch identity and extra termsDerived label if omitted
CommandItem.onSelect / disabledAction and availability— / false
CommandGroup.headingRelated-action label—
CommandDialog.open / onOpenChangeDialog visibilityUncontrolled
CommandShortcutVisual annotationNo event handler
CommandDialog.titleAccessible dialog titleCommand Palette
CommandDialog.descriptionAccessible dialog descriptionSearch for a command to run...
CommandDialog.showCloseButtonBuilt-in dialog close controlfalse

#Accessibility

Label the search field and provide useful no-results feedback. Arrow keys navigate enabled items; Enter chooses an item. Keep action labels meaningful and register real keyboard shortcuts separately. For a command dialog, verify Escape and focus return. Use loading and failure feedback for remote searches rather than presenting an empty result as success.