Search

Search documentation

Command

Fast, composable, unstyled command menu for React.

Installation

pnpm dlx shadcn@latest add @evolphin/command

Usage

import {
  Command,
  CommandDialog,
  CommandEmpty,
  CommandGroup,
  CommandInput,
  CommandItem,
  CommandList,
  CommandSeparator,
  CommandShortcut,
} from "@/components/ui/command";
<Command>
  <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>

Type Definitions

interface CommandProps {
  /** The value of the filtered query */
  value?: string;
CommandProps.value?: string | undefined

The value of the filtered query

/** Event handler called when the value changes */ ?: (: string) => void; /** Whether the command menu matches keys filter */ ?: (: string, : string) => number; }

Examples

Default

Dialog

To use the command menu as a dialog, import CommandDialog.

<CommandDialog open={open} onOpenChange={setOpen}>
  <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>
  </CommandList>
</CommandDialog>

API Reference

Command

PropTypeDefaultDescription
valuestring-The value of the filtered query.
onValueChange(value: string) => void-Event handler called when the value changes.
loopbooleanfalseWhether to loop through items when navigating.
classNamestring-Additional CSS classes

CommandInput

PropTypeDefaultDescription
placeholderstring-The placeholder text for the input.
valuestring-The value of the input.
onValueChange(value: string) => void-Event handler called when the value changes.

CommandList

PropTypeDefaultDescription
classNamestring-Additional CSS classes

CommandEmpty

PropTypeDefaultDescription
classNamestring-Additional CSS classes

CommandGroup

PropTypeDefaultDescription
headingReact.ReactNode-The heading of the group.
classNamestring-Additional CSS classes

CommandItem

PropTypeDefaultDescription
valuestring-The value of the item.
onSelect(value: string) => void-Event handler called when the item is selected.
disabledbooleanfalseWhether the item is disabled.

CommandShortcut

PropTypeDefaultDescription
classNamestring-Additional CSS classes

On this page