Command
View on shadcn/uiA command menu for quick navigation and actions.
No results found.
Calendar
Emoji picker
Billing
Profile⌘P
Settings⌘S
About
The Command component is built on top of cmdk, a command menu component for React.
Installation
pnpm dlx shadcn@latest add https://designsystem.wfp.org/r/command.jsonUsage
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>Settings</CommandItem>
</CommandGroup>
</CommandList>
</Command>Examples
Dialog
Press ⌘G
Command Palette
Search for a command to run...
Use the CommandDialog component to show the command menu in a dialog.
const [open, setOpen] = useState(false);
useEffect(() => {
const down = (e: KeyboardEvent) => {
if (e.key === "g" && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
setOpen((open) => !open);
}
};
document.addEventListener("keydown", down);
return () => document.removeEventListener("keydown", down);
}, []);API reference
This component is built on top of cmdk. See the cmdk documentation for the full API reference.