Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Code Block
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Direction
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Marker
- Message
- Message Scroller
- Native Select
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Tooltip
- Trace
- Typography
AI Elements
Get Started
@shadcn/react
@shadcn/helpers
Utilities
Calendar
Search Emoji
Calculator
Profile⌘P
Billing⌘B
Settings⌘S
No results found.
"use client"
import {Installation#
pnpm dlx shadcn@latest add command
Install the following dependencies:
pnpm add react-aria-components
Copy and paste the following code into your project.
"use client"
import * as React from "react"
import { cn } from "cn"
import { CheckIcon, SearchIcon } from "lucide-react"
import {
Autocomplete,
Collection,
composeRenderProps,
Header,
Input,
Menu,
MenuItem,
MenuSection,
SearchField,
Separator,
useFilter,
type AutocompleteProps,
type InputProps,
type MenuItemProps,
type MenuProps,
type MenuSectionProps,
type SeparatorProps,
} from "react-aria-components"
import {
Dialog,
DialogDescription,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog"
import { InputGroup, InputGroupAddon } from "@/components/ui/input-group"
function Command({
className,
dir,
style,
...props
}: Omit<AutocompleteProps, "className" | "style"> & {
className?: string
dir?: React.HTMLAttributes<HTMLDivElement>["dir"]
style?: React.CSSProperties
}) {
const { contains } = useFilter({ sensitivity: "base" })
return (
<div
data-slot="command"
dir={dir}
className={cn(
"flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",
className
)}
style={style}
>
<Autocomplete {...props} filter={props.filter || contains}>
{props.children}
</Autocomplete>
</div>
)
}
function CommandDialog({
title = "Command Palette",
description = "Search for a command to run...",
children,
open,
onOpenChange,
className,
showCloseButton = false,
...props
}: Omit<
React.ComponentProps<typeof Dialog>,
"children" | "className" | "isOpen" | "onOpenChange"
> & {
title?: string
description?: string
open?: boolean
onOpenChange?: (isOpen: boolean) => void
className?: string
showCloseButton?: boolean
children: React.ReactNode
}) {
return (
<Dialog
isOpen={open}
onOpenChange={onOpenChange}
className={cn(
"top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0",
className
)}
showCloseButton={showCloseButton}
isDismissable
{...props}
>
<DialogHeader className="sr-only">
<DialogTitle>{title}</DialogTitle>
<DialogDescription>{description}</DialogDescription>
</DialogHeader>
{children}
</Dialog>
)
}
function CommandInput({ className, ...props }: InputProps) {
return (
<SearchField
autoFocus
aria-label={props.placeholder || "Search"}
data-slot="command-input-wrapper"
className="p-1 pb-0"
>
<InputGroup className="h-8! rounded-lg! border-input/30 bg-input/30 shadow-none! *:data-[slot=input-group-addon]:pl-2!">
<Input
{...props}
data-slot="command-input"
className={cn(
"w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50 [&::-webkit-search-cancel-button]:hidden",
className
)}
/>
<InputGroupAddon>
<SearchIcon className="size-4 shrink-0 opacity-50" />
</InputGroupAddon>
</InputGroup>
</SearchField>
)
}
function CommandList<T extends object>({ className, ...props }: MenuProps<T>) {
return (
<Menu
{...props}
data-slot="command-list"
className={cn(
"no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",
className
)}
/>
)
}
function CommandEmpty({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="command-empty"
className={cn("py-6 text-center text-sm", className)}
{...props}
/>
)
}
function CommandGroup<T extends object>({
className,
children,
items,
heading,
...props
}: MenuSectionProps<T> & { heading?: string }) {
return (
<MenuSection
data-slot="command-group"
className={cn(
"overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",
className
)}
{...props}
>
{heading && <Header cmdk-group-heading="">{heading}</Header>}
<Collection items={items}>{children}</Collection>
</MenuSection>
)
}
function CommandSeparator({ className, ...props }: SeparatorProps) {
return (
<Separator
data-slot="command-separator"
className={cn("-mx-1 h-px bg-border", className)}
{...props}
/>
)
}
function CommandItem<T extends object>({
className,
children,
textValue,
...props
}: MenuItemProps<T>) {
return (
<MenuItem
{...props}
data-slot="command-item"
className={cn(
"group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-focused:bg-muted data-focused:text-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-focused:*:[svg]:text-foreground data-selected:*:[svg]:text-foreground",
className
)}
textValue={
textValue || (typeof children === "string" ? children : undefined)
}
>
{composeRenderProps(children, (children) => (
<>
{children}
<CheckIcon className="ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100" />
</>
))}
</MenuItem>
)
}
function CommandShortcut({
className,
...props
}: React.ComponentProps<"span">) {
return (
<span
data-slot="command-shortcut"
className={cn(
"ml-auto text-xs tracking-widest text-muted-foreground group-data-focused/command-item:text-foreground group-data-selected/command-item:text-foreground",
className
)}
{...props}
/>
)
}
export {
Command,
CommandDialog,
CommandInput,
CommandList,
CommandEmpty,
CommandGroup,
CommandItem,
CommandShortcut,
CommandSeparator,
}
Update the import paths to match your project setup.
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
renderEmptyState={() => <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>Composition#
Use the following composition to build a Command:
Command
├── CommandInput
└── CommandList
├── CommandGroup
│ ├── CommandItem
│ └── CommandItem
├── CommandSeparator
└── CommandGroup
├── CommandItem
└── CommandItemBasic#
A simple command menu in a dialog.
"use client"
import * as React from "react""use client"
import * as React from "react"
import { Button } from "@/components/ui/button"
import {
Command,
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from "@/components/ui/command"
export function CommandBasic() {
const [open, setOpen] = React.useState(false)
return (
<div className="flex flex-col gap-4">
<Button onClick={() => setOpen(true)} variant="outline" className="w-fit">
Open Menu
</Button>
<CommandDialog open={open} onOpenChange={setOpen}>
<Command>
<CommandInput placeholder="Type a command or search..." />
<CommandList
renderEmptyState={() => (
<CommandEmpty>No results found.</CommandEmpty>
)}
>
<CommandGroup heading="Suggestions">
<CommandItem>Calendar</CommandItem>
<CommandItem>Search Emoji</CommandItem>
<CommandItem>Calculator</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</CommandDialog>
</div>
)
}
Shortcuts#
"use client"
import * as React from "react""use client"
import * as React from "react"
import { CreditCardIcon, SettingsIcon, UserIcon } from "lucide-react"
import { Button } from "@/components/ui/button"
import {
Command,
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandShortcut,
} from "@/components/ui/command"
export function CommandWithShortcuts() {
const [open, setOpen] = React.useState(false)
return (
<div className="flex flex-col gap-4">
<Button onClick={() => setOpen(true)} variant="outline" className="w-fit">
Open Menu
</Button>
<CommandDialog open={open} onOpenChange={setOpen}>
<Command>
<CommandInput placeholder="Type a command or search..." />
<CommandList
renderEmptyState={() => (
<CommandEmpty>No results found.</CommandEmpty>
)}
>
<CommandGroup heading="Settings">
<CommandItem textValue="Profile">
<UserIcon />
<span>Profile</span>
<CommandShortcut>⌘P</CommandShortcut>
</CommandItem>
<CommandItem textValue="Billing">
<CreditCardIcon />
<span>Billing</span>
<CommandShortcut>⌘B</CommandShortcut>
</CommandItem>
<CommandItem textValue="Settings">
<SettingsIcon />
<span>Settings</span>
<CommandShortcut>⌘S</CommandShortcut>
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</CommandDialog>
</div>
)
}
Groups#
A command menu with groups, icons and separators.
"use client"
import * as React from "react""use client"
import * as React from "react"
import {
CalculatorIcon,
CalendarIcon,
CreditCardIcon,
SettingsIcon,
SmileIcon,
UserIcon,
} from "lucide-react"
import { Button } from "@/components/ui/button"
import {
Command,
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
} from "@/components/ui/command"
export function CommandWithGroups() {
const [open, setOpen] = React.useState(false)
return (
<div className="flex flex-col gap-4">
<Button onClick={() => setOpen(true)} variant="outline" className="w-fit">
Open Menu
</Button>
<CommandDialog open={open} onOpenChange={setOpen}>
<Command>
<CommandInput placeholder="Type a command or search..." />
<CommandList
renderEmptyState={() => (
<CommandEmpty>No results found.</CommandEmpty>
)}
>
<CommandGroup heading="Suggestions">
<CommandItem textValue="Calendar">
<CalendarIcon />
<span>Calendar</span>
</CommandItem>
<CommandItem textValue="Search Emoji">
<SmileIcon />
<span>Search Emoji</span>
</CommandItem>
<CommandItem textValue="Calculator">
<CalculatorIcon />
<span>Calculator</span>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="Settings">
<CommandItem textValue="Profile">
<UserIcon />
<span>Profile</span>
<CommandShortcut>⌘P</CommandShortcut>
</CommandItem>
<CommandItem textValue="Billing">
<CreditCardIcon />
<span>Billing</span>
<CommandShortcut>⌘B</CommandShortcut>
</CommandItem>
<CommandItem textValue="Settings">
<SettingsIcon />
<span>Settings</span>
<CommandShortcut>⌘S</CommandShortcut>
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</CommandDialog>
</div>
)
}
Scrollable#
Scrollable command menu with multiple items.
"use client"
import * as React from "react""use client"
import * as React from "react"
import {
BellIcon,
CalculatorIcon,
CalendarIcon,
ClipboardPasteIcon,
CodeIcon,
CopyIcon,
CreditCardIcon,
FileTextIcon,
FolderIcon,
FolderPlusIcon,
HelpCircleIcon,
HomeIcon,
ImageIcon,
InboxIcon,
LayoutGridIcon,
ListIcon,
PlusIcon,
ScissorsIcon,
SettingsIcon,
TrashIcon,
UserIcon,
ZoomInIcon,
ZoomOutIcon,
} from "lucide-react"
import { Button } from "@/components/ui/button"
import {
Command,
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
} from "@/components/ui/command"
export function CommandManyItems() {
const [open, setOpen] = React.useState(false)
return (
<div className="flex flex-col gap-4">
<Button onClick={() => setOpen(true)} variant="outline" className="w-fit">
Open Menu
</Button>
<CommandDialog open={open} onOpenChange={setOpen}>
<Command>
<CommandInput placeholder="Type a command or search..." />
<CommandList
renderEmptyState={() => (
<CommandEmpty>No results found.</CommandEmpty>
)}
>
<CommandGroup heading="Navigation">
<CommandItem textValue="Home">
<HomeIcon />
<span>Home</span>
<CommandShortcut>⌘H</CommandShortcut>
</CommandItem>
<CommandItem textValue="Inbox">
<InboxIcon />
<span>Inbox</span>
<CommandShortcut>⌘I</CommandShortcut>
</CommandItem>
<CommandItem textValue="Documents">
<FileTextIcon />
<span>Documents</span>
<CommandShortcut>⌘D</CommandShortcut>
</CommandItem>
<CommandItem textValue="Folders">
<FolderIcon />
<span>Folders</span>
<CommandShortcut>⌘F</CommandShortcut>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="Actions">
<CommandItem textValue="New File">
<PlusIcon />
<span>New File</span>
<CommandShortcut>⌘N</CommandShortcut>
</CommandItem>
<CommandItem textValue="New Folder">
<FolderPlusIcon />
<span>New Folder</span>
<CommandShortcut>⇧⌘N</CommandShortcut>
</CommandItem>
<CommandItem textValue="Copy">
<CopyIcon />
<span>Copy</span>
<CommandShortcut>⌘C</CommandShortcut>
</CommandItem>
<CommandItem textValue="Cut">
<ScissorsIcon />
<span>Cut</span>
<CommandShortcut>⌘X</CommandShortcut>
</CommandItem>
<CommandItem textValue="Paste">
<ClipboardPasteIcon />
<span>Paste</span>
<CommandShortcut>⌘V</CommandShortcut>
</CommandItem>
<CommandItem textValue="Delete">
<TrashIcon />
<span>Delete</span>
<CommandShortcut>⌫</CommandShortcut>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="View">
<CommandItem textValue="Grid View">
<LayoutGridIcon />
<span>Grid View</span>
</CommandItem>
<CommandItem textValue="List View">
<ListIcon />
<span>List View</span>
</CommandItem>
<CommandItem textValue="Zoom In">
<ZoomInIcon />
<span>Zoom In</span>
<CommandShortcut>⌘+</CommandShortcut>
</CommandItem>
<CommandItem textValue="Zoom Out">
<ZoomOutIcon />
<span>Zoom Out</span>
<CommandShortcut>⌘-</CommandShortcut>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="Account">
<CommandItem textValue="Profile">
<UserIcon />
<span>Profile</span>
<CommandShortcut>⌘P</CommandShortcut>
</CommandItem>
<CommandItem textValue="Billing">
<CreditCardIcon />
<span>Billing</span>
<CommandShortcut>⌘B</CommandShortcut>
</CommandItem>
<CommandItem textValue="Settings">
<SettingsIcon />
<span>Settings</span>
<CommandShortcut>⌘S</CommandShortcut>
</CommandItem>
<CommandItem textValue="Notifications">
<BellIcon />
<span>Notifications</span>
</CommandItem>
<CommandItem textValue="Help & Support">
<HelpCircleIcon />
<span>Help & Support</span>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="Tools">
<CommandItem textValue="Calculator">
<CalculatorIcon />
<span>Calculator</span>
</CommandItem>
<CommandItem textValue="Calendar">
<CalendarIcon />
<span>Calendar</span>
</CommandItem>
<CommandItem textValue="Image Editor">
<ImageIcon />
<span>Image Editor</span>
</CommandItem>
<CommandItem textValue="Code Editor">
<CodeIcon />
<span>Code Editor</span>
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</CommandDialog>
</div>
)
}
RTL#
To enable RTL support in shadcn/ui, see the RTL configuration guide.
التقويم
البحث عن الرموز التعبيرية
الآلة الحاسبة
الملف الشخصي⌘P
الفوترة⌘B
الإعدادات⌘S
لم يتم العثور على نتائج.
"use client"
import * as React from "react"// You will notice this example uses dir and data-lang attributes. // This is because this site is not RTL by default. // In your application, you won't need these.// See the RTL guide for more information.
"use client"
import * as React from "react"
import {
Calculator,
Calendar,
CreditCard,
Settings,
Smile,
User,
} from "lucide-react"
import {
useTranslation,
type Translations,
} from "@/components/language-selector"
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
} from "@/components/ui/command"
const translations: Translations = {
en: {
dir: "ltr",
values: {
placeholder: "Type a command or search...",
empty: "No results found.",
suggestions: "Suggestions",
calendar: "Calendar",
searchEmoji: "Search Emoji",
calculator: "Calculator",
settings: "Settings",
profile: "Profile",
billing: "Billing",
},
},
ar: {
dir: "rtl",
values: {
placeholder: "اكتب أمرًا أو ابحث...",
empty: "لم يتم العثور على نتائج.",
suggestions: "اقتراحات",
calendar: "التقويم",
searchEmoji: "البحث عن الرموز التعبيرية",
calculator: "الآلة الحاسبة",
settings: "الإعدادات",
profile: "الملف الشخصي",
billing: "الفوترة",
},
},
he: {
dir: "rtl",
values: {
placeholder: "הקלד פקודה או חפש...",
empty: "לא נמצאו תוצאות.",
suggestions: "הצעות",
calendar: "לוח שנה",
searchEmoji: "חפש אמוג'י",
calculator: "מחשבון",
settings: "הגדרות",
profile: "פרופיל",
billing: "חיוב",
},
},
}
export function CommandRtl() {
const { dir, t } = useTranslation(translations, "ar")
return (
<Command className="max-w-sm rounded-lg border" dir={dir}>
<CommandInput placeholder={t.placeholder} dir={dir} />
<CommandList
renderEmptyState={() => <CommandEmpty>{t.empty}</CommandEmpty>}
>
<CommandGroup heading={t.suggestions}>
<CommandItem textValue={t.calendar}>
<Calendar />
<span>{t.calendar}</span>
</CommandItem>
<CommandItem textValue={t.searchEmoji}>
<Smile />
<span>{t.searchEmoji}</span>
</CommandItem>
<CommandItem textValue={t.calculator} isDisabled>
<Calculator />
<span>{t.calculator}</span>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading={t.settings}>
<CommandItem textValue={t.profile}>
<User />
<span>{t.profile}</span>
<CommandShortcut>⌘P</CommandShortcut>
</CommandItem>
<CommandItem textValue={t.billing}>
<CreditCard />
<span>{t.billing}</span>
<CommandShortcut>⌘B</CommandShortcut>
</CommandItem>
<CommandItem textValue={t.settings}>
<Settings />
<span>{t.settings}</span>
<CommandShortcut>⌘S</CommandShortcut>
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
)
}
API Reference#
See the React Aria documentation for more information.
Deploy your shadcn/ui app on Vercel
Trusted by OpenAI, Sonos, Adobe, and more.
Vercel provides tools and infrastructure to deploy apps and features at scale.
Deploy to Vercel