Command Palette

Search for a command to run...

Command

shadcn/ui

Fast, composable, unstyled command menu for React.

Command
Suggestions
Calendar
Search Emoji
Calculator
Settings
Profile⌘P
Billing⌘B
Settings⌘S

import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut } from "@/components/optics/command";import { Calculator, Calendar, CreditCard, Settings, Smile, User } from "lucide-react";<Command className="rounded-lg border shadow-md max-w-md">  <CommandInput placeholder="Type a command or search..." />  <CommandList>    <CommandEmpty>      No results found.    </CommandEmpty>    <CommandGroup heading="Suggestions">      <CommandItem>        <Calendar className="mr-2 h-4 w-4" />        <span>          Calendar        </span>      </CommandItem>      <CommandItem>        <FaceSlightlySmiling className="mr-2 h-4 w-4" />        <span>          Search Emoji        </span>      </CommandItem>      <CommandItem>        <Calculator className="mr-2 h-4 w-4" />        <span>          Calculator        </span>      </CommandItem>    </CommandGroup>    <CommandSeparator />    <CommandGroup heading="Settings">      <CommandItem>        <User className="mr-2 h-4 w-4" />        <span>          Profile        </span>        <CommandShortcut>          ⌘P        </CommandShortcut>      </CommandItem>      <CommandItem>        <CreditCard className="mr-2 h-4 w-4" />        <span>          Billing        </span>        <CommandShortcut>          ⌘B        </CommandShortcut>      </CommandItem>      <CommandItem>        <Settings className="mr-2 h-4 w-4" />        <span>          Settings        </span>        <CommandShortcut>          ⌘S        </CommandShortcut>      </CommandItem>    </CommandGroup>  </CommandList></Command>

Installation

pnpm dlx shadcn@latest add @optics/command

Props

<Command />
Name
Type
shouldFilter
boolean(default: true)
filter
((value: string, search: string, keywords?: string[]) => number)
loop
boolean(default: true)
render
React.ReactElement

<CommandDialog />
Name
Type
description
string(default: Search for a command to run...)
showCloseButton
boolean(default: false)
onOpenChange
(...args) => void
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
triggerId
string
defaultTriggerId
string
modal
boolean | "trap-focus"
disablePointerDismissal
boolean
render
React.ReactElement
<CommandInput />
Name
Type
onValueChange
((search: string) => void)
render
React.ReactElement
<CommandList />
Name
Type
render
React.ReactElement
<CommandEmpty />
Name
Type
render
React.ReactElement
<CommandGroup />
Name
Type
heading
React.ReactNode
render
React.ReactElement
<CommandItem />
Name
Type
keywords
string[]
onPointerMove
React.PointerEventHandler<HTMLDivElement>
render
React.ReactElement
<CommandShortcut />
Name
Type
render
React.ReactElement
<CommandSeparator />
Name
Type
render
React.ReactElement