Search every page in the navigation.
Command menu for search and quick actions.
import {
IconCalculator,
IconCalendar,
IconCreditCard,
IconMoodSmile,
IconSettings,
IconUser,
} from "@tabler/icons-react"
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
} from "@/components/ui/command"
function CommandDemo() {
return (
<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>
<IconCalendar />
<span>Calendar</span>
</CommandItem>
<CommandItem>
<IconMoodSmile />
<span>Search Emoji</span>
</CommandItem>
<CommandItem disabled>
<IconCalculator />
<span>Calculator</span>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="Settings">
<CommandItem>
<IconUser />
<span>Profile</span>
<CommandShortcut>โP</CommandShortcut>
</CommandItem>
<CommandItem>
<IconCreditCard />
<span>Billing</span>
<CommandShortcut>โB</CommandShortcut>
</CommandItem>
<CommandItem>
<IconSettings />
<span>Settings</span>
<CommandShortcut>โS</CommandShortcut>
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
)
}
export default CommandDemoThe <Command /> component uses the cmdk component by Dip.
npx shadcn@latest add @ziiz/commandimport {
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>Use the following composition to build a Command:
Command
โโโ CommandInput
โโโ CommandList
โโโ CommandEmpty
โโโ CommandGroup
โ โโโ CommandItem
โ โโโ CommandItem
โโโ CommandSeparator
โโโ CommandGroup
โโโ CommandItem
โโโ CommandItemA simple command menu in a dialog.
Search for a command to run...
"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"
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>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading="Suggestions">
<CommandItem>Calendar</CommandItem>
<CommandItem>Search Emoji</CommandItem>
<CommandItem>Calculator</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</CommandDialog>
</div>
)
}
export default CommandBasicSearch for a command to run...
"use client"
import * as React from "react"
import { IconCreditCard, IconSettings, IconUser } from "@tabler/icons-react"
import { Button } from "@/components/ui/button"
import {
Command,
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandShortcut,
} from "@/components/ui/command"
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>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading="Settings">
<CommandItem>
<IconUser />
<span>Profile</span>
<CommandShortcut>โP</CommandShortcut>
</CommandItem>
<CommandItem>
<IconCreditCard />
<span>Billing</span>
<CommandShortcut>โB</CommandShortcut>
</CommandItem>
<CommandItem>
<IconSettings />
<span>Settings</span>
<CommandShortcut>โS</CommandShortcut>
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</CommandDialog>
</div>
)
}
export default CommandWithShortcutsA command menu with groups, icons and separators.
Search for a command to run...
"use client"
import * as React from "react"
import {
IconCalculator,
IconCalendar,
IconCreditCard,
IconMoodSmile,
IconSettings,
IconUser,
} from "@tabler/icons-react"
import { Button } from "@/components/ui/button"
import {
Command,
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
} from "@/components/ui/command"
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>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading="Suggestions">
<CommandItem>
<IconCalendar />
<span>Calendar</span>
</CommandItem>
<CommandItem>
<IconMoodSmile />
<span>Search Emoji</span>
</CommandItem>
<CommandItem>
<IconCalculator />
<span>Calculator</span>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="Settings">
<CommandItem>
<IconUser />
<span>Profile</span>
<CommandShortcut>โP</CommandShortcut>
</CommandItem>
<CommandItem>
<IconCreditCard />
<span>Billing</span>
<CommandShortcut>โB</CommandShortcut>
</CommandItem>
<CommandItem>
<IconSettings />
<span>Settings</span>
<CommandShortcut>โS</CommandShortcut>
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</CommandDialog>
</div>
)
}
export default CommandWithGroupsScrollable command menu with multiple items.
Search for a command to run...
"use client"
import * as React from "react"
import {
IconBell,
IconCalculator,
IconCalendar,
IconClipboard,
IconCode,
IconCopy,
IconCreditCard,
IconFileText,
IconFolder,
IconFolderPlus,
IconHelpCircle,
IconHome,
IconInbox,
IconLayoutGrid,
IconList,
IconPhoto,
IconPlus,
IconScissors,
IconSettings,
IconTrash,
IconUser,
IconZoomIn,
IconZoomOut,
} from "@tabler/icons-react"
import { Button } from "@/components/ui/button"
import {
Command,
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
} from "@/components/ui/command"
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>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading="Navigation">
<CommandItem>
<IconHome />
<span>Home</span>
<CommandShortcut>โH</CommandShortcut>
</CommandItem>
<CommandItem>
<IconInbox />
<span>Inbox</span>
<CommandShortcut>โI</CommandShortcut>
</CommandItem>
<CommandItem>
<IconFileText />
<span>Documents</span>
<CommandShortcut>โD</CommandShortcut>
</CommandItem>
<CommandItem>
<IconFolder />
<span>Folders</span>
<CommandShortcut>โF</CommandShortcut>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="Actions">
<CommandItem>
<IconPlus />
<span>New File</span>
<CommandShortcut>โN</CommandShortcut>
</CommandItem>
<CommandItem>
<IconFolderPlus />
<span>New Folder</span>
<CommandShortcut>โงโN</CommandShortcut>
</CommandItem>
<CommandItem>
<IconCopy />
<span>Copy</span>
<CommandShortcut>โC</CommandShortcut>
</CommandItem>
<CommandItem>
<IconScissors />
<span>Cut</span>
<CommandShortcut>โX</CommandShortcut>
</CommandItem>
<CommandItem>
<IconClipboard />
<span>Paste</span>
<CommandShortcut>โV</CommandShortcut>
</CommandItem>
<CommandItem>
<IconTrash />
<span>Delete</span>
<CommandShortcut>โซ</CommandShortcut>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="View">
<CommandItem>
<IconLayoutGrid />
<span>Grid View</span>
</CommandItem>
<CommandItem>
<IconList />
<span>List View</span>
</CommandItem>
<CommandItem>
<IconZoomIn />
<span>Zoom In</span>
<CommandShortcut>โ+</CommandShortcut>
</CommandItem>
<CommandItem>
<IconZoomOut />
<span>Zoom Out</span>
<CommandShortcut>โ-</CommandShortcut>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="Account">
<CommandItem>
<IconUser />
<span>Profile</span>
<CommandShortcut>โP</CommandShortcut>
</CommandItem>
<CommandItem>
<IconCreditCard />
<span>Billing</span>
<CommandShortcut>โB</CommandShortcut>
</CommandItem>
<CommandItem>
<IconSettings />
<span>Settings</span>
<CommandShortcut>โS</CommandShortcut>
</CommandItem>
<CommandItem>
<IconBell />
<span>Notifications</span>
</CommandItem>
<CommandItem>
<IconHelpCircle />
<span>Help & Support</span>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="Tools">
<CommandItem>
<IconCalculator />
<span>Calculator</span>
</CommandItem>
<CommandItem>
<IconCalendar />
<span>Calendar</span>
</CommandItem>
<CommandItem>
<IconPhoto />
<span>Image Editor</span>
</CommandItem>
<CommandItem>
<IconCode />
<span>Code Editor</span>
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</CommandDialog>
</div>
)
}
export default CommandManyItemsSee the cmdk documentation for more information.