Command
Command menu for search and quick actions.
Kobalte
Suggestions
Calendar
Search Emoji
Calculator
Settings
Profile⌘P
Billing⌘B
Settings⌘S
import { Calculator, Calendar, CreditCard, Settings, Smile, User } from "lucide-solid";import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut,} from "~/components/ui/command";
export default function CommandDemo() { return ( <Command class="max-w-sm rounded-lg border"> <CommandInput placeholder="Type a command or search..." /> <CommandList> <CommandEmpty>No results found.</CommandEmpty> <CommandGroup heading="Suggestions"> <CommandItem value="calendar"> <Calendar /> <span>Calendar</span> </CommandItem> <CommandItem value="search-emoji"> <Smile /> <span>Search Emoji</span> </CommandItem> <CommandItem value="calculator" disabled> <Calculator /> <span>Calculator</span> </CommandItem> </CommandGroup> <CommandSeparator /> <CommandGroup heading="Settings"> <CommandItem value="profile"> <User /> <span>Profile</span> <CommandShortcut>⌘P</CommandShortcut> </CommandItem> <CommandItem value="billing"> <CreditCard /> <span>Billing</span> <CommandShortcut>⌘B</CommandShortcut> </CommandItem> <CommandItem value="settings"> <Settings /> <span>Settings</span> <CommandShortcut>⌘S</CommandShortcut> </CommandItem> </CommandGroup> </CommandList> </Command> );}About
The <Command /> component is built with cmdk-solid, and CommandDialog composes Kobalte Dialog for accessible modal and keyboard behavior.
Installation
Usage
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut,} from "~/components/ui/command";<Command class="max-w-sm rounded-lg border"> <CommandInput placeholder="Type a command or search..." /> <CommandList> <CommandEmpty>No results found.</CommandEmpty> <CommandGroup heading="Suggestions"> <CommandItem value="calendar">Calendar</CommandItem> <CommandItem value="search-emoji">Search Emoji</CommandItem> <CommandItem value="calculator">Calculator</CommandItem> </CommandGroup> <CommandSeparator /> <CommandGroup heading="Settings"> <CommandItem value="profile">Profile</CommandItem> <CommandItem value="billing">Billing</CommandItem> <CommandItem value="settings">Settings</CommandItem> </CommandGroup> </CommandList></Command>Composition
Use the following composition to build a Command:
Command├── CommandInput└── CommandList ├── CommandEmpty ├── CommandGroup │ ├── CommandItem │ └── CommandItem ├── CommandSeparator └── CommandGroup ├── CommandItem └── CommandItemBasic
A simple command menu in a dialog.
Command Palette
Search for a command to run...
import { createSignal } from "solid-js";import { Button } from "~/components/ui/button";import { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList,} from "~/components/ui/command";
export default function CommandBasic() { const [open, setOpen] = createSignal(false);
return ( <div class="flex flex-col gap-4"> <Button onClick={() => setOpen(true)} variant="outline" class="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 value="calendar">Calendar</CommandItem> <CommandItem value="search-emoji">Search Emoji</CommandItem> <CommandItem value="calculator">Calculator</CommandItem> </CommandGroup> </CommandList> </Command> </CommandDialog> </div> );}Shortcuts
Command Palette
Search for a command to run...
import { CreditCard, Settings, User } from "lucide-solid";import { createSignal } from "solid-js";import { Button } from "~/components/ui/button";import { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandShortcut,} from "~/components/ui/command";
export default function CommandShortcuts() { const [open, setOpen] = createSignal(false);
return ( <div class="flex flex-col gap-4"> <Button onClick={() => setOpen(true)} variant="outline" class="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 value="profile"> <User /> <span>Profile</span> <CommandShortcut>⌘P</CommandShortcut> </CommandItem> <CommandItem value="billing"> <CreditCard /> <span>Billing</span> <CommandShortcut>⌘B</CommandShortcut> </CommandItem> <CommandItem value="settings"> <Settings /> <span>Settings</span> <CommandShortcut>⌘S</CommandShortcut> </CommandItem> </CommandGroup> </CommandList> </Command> </CommandDialog> </div> );}Groups
A command menu with groups, icons, and separators.
Command Palette
Search for a command to run...
import { Calculator, Calendar, CreditCard, Settings, Smile, User } from "lucide-solid";import { createSignal } from "solid-js";import { Button } from "~/components/ui/button";import { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut,} from "~/components/ui/command";
export default function CommandGroups() { const [open, setOpen] = createSignal(false);
return ( <div class="flex flex-col gap-4"> <Button onClick={() => setOpen(true)} variant="outline" class="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 value="calendar"> <Calendar /> <span>Calendar</span> </CommandItem> <CommandItem value="search-emoji"> <Smile /> <span>Search Emoji</span> </CommandItem> <CommandItem value="calculator"> <Calculator /> <span>Calculator</span> </CommandItem> </CommandGroup> <CommandSeparator /> <CommandGroup heading="Settings"> <CommandItem value="profile"> <User /> <span>Profile</span> <CommandShortcut>⌘P</CommandShortcut> </CommandItem> <CommandItem value="billing"> <CreditCard /> <span>Billing</span> <CommandShortcut>⌘B</CommandShortcut> </CommandItem> <CommandItem value="settings"> <Settings /> <span>Settings</span> <CommandShortcut>⌘S</CommandShortcut> </CommandItem> </CommandGroup> </CommandList> </Command> </CommandDialog> </div> );}Scrollable
Scrollable command menu with multiple items.
Command Palette
Search for a command to run...
import { Bell, Calculator, Calendar, ClipboardPaste, Code, Copy, CreditCard, FileText, Folder, FolderPlus, HelpCircle, Home, Image, Inbox, LayoutGrid, List, Plus, Scissors, Settings, Trash, User, ZoomIn, ZoomOut,} from "lucide-solid";import { createSignal } from "solid-js";import { Button } from "~/components/ui/button";import { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut,} from "~/components/ui/command";
export default function CommandScrollable() { const [open, setOpen] = createSignal(false);
return ( <div class="flex flex-col gap-4"> <Button onClick={() => setOpen(true)} variant="outline" class="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 value="home"> <Home /> <span>Home</span> <CommandShortcut>⌘H</CommandShortcut> </CommandItem> <CommandItem value="inbox"> <Inbox /> <span>Inbox</span> <CommandShortcut>⌘I</CommandShortcut> </CommandItem> <CommandItem value="documents"> <FileText /> <span>Documents</span> <CommandShortcut>⌘D</CommandShortcut> </CommandItem> <CommandItem value="folders"> <Folder /> <span>Folders</span> <CommandShortcut>⌘F</CommandShortcut> </CommandItem> </CommandGroup> <CommandSeparator /> <CommandGroup heading="Actions"> <CommandItem value="new-file"> <Plus /> <span>New File</span> <CommandShortcut>⌘N</CommandShortcut> </CommandItem> <CommandItem value="new-folder"> <FolderPlus /> <span>New Folder</span> <CommandShortcut>⇧⌘N</CommandShortcut> </CommandItem> <CommandItem value="copy"> <Copy /> <span>Copy</span> <CommandShortcut>⌘C</CommandShortcut> </CommandItem> <CommandItem value="cut"> <Scissors /> <span>Cut</span> <CommandShortcut>⌘X</CommandShortcut> </CommandItem> <CommandItem value="paste"> <ClipboardPaste /> <span>Paste</span> <CommandShortcut>⌘V</CommandShortcut> </CommandItem> <CommandItem value="delete"> <Trash /> <span>Delete</span> <CommandShortcut>⌫</CommandShortcut> </CommandItem> </CommandGroup> <CommandSeparator /> <CommandGroup heading="View"> <CommandItem value="grid-view"> <LayoutGrid /> <span>Grid View</span> </CommandItem> <CommandItem value="list-view"> <List /> <span>List View</span> </CommandItem> <CommandItem value="zoom-in"> <ZoomIn /> <span>Zoom In</span> <CommandShortcut>⌘+</CommandShortcut> </CommandItem> <CommandItem value="zoom-out"> <ZoomOut /> <span>Zoom Out</span> <CommandShortcut>⌘-</CommandShortcut> </CommandItem> </CommandGroup> <CommandSeparator /> <CommandGroup heading="Account"> <CommandItem value="profile"> <User /> <span>Profile</span> <CommandShortcut>⌘P</CommandShortcut> </CommandItem> <CommandItem value="billing"> <CreditCard /> <span>Billing</span> <CommandShortcut>⌘B</CommandShortcut> </CommandItem> <CommandItem value="settings"> <Settings /> <span>Settings</span> <CommandShortcut>⌘S</CommandShortcut> </CommandItem> <CommandItem value="notifications"> <Bell /> <span>Notifications</span> </CommandItem> <CommandItem value="help"> <HelpCircle /> <span>Help & Support</span> </CommandItem> </CommandGroup> <CommandSeparator /> <CommandGroup heading="Tools"> <CommandItem value="calculator"> <Calculator /> <span>Calculator</span> </CommandItem> <CommandItem value="calendar"> <Calendar /> <span>Calendar</span> </CommandItem> <CommandItem value="image-editor"> <Image /> <span>Image Editor</span> </CommandItem> <CommandItem value="code-editor"> <Code /> <span>Code Editor</span> </CommandItem> </CommandGroup> </CommandList> </Command> </CommandDialog> </div> );}API Reference
For command props, filtering, and keyboard behavior, see the cmdk-solid API reference.