ui
Command
A command palette component for quick actions and navigation with keyboard shortcuts.
1. Import
Import the Command component from the design system.
import {
Command,
CommandDialog,
CommandInput,
CommandList,
CommandItem,
CommandGroup,
} from "@/design-system/components/ui/command";2. Props
Command component props.
| Prop | Type | Default |
|---|---|---|
| open | boolean | false |
| onOpenChange | (open: boolean) => void | -- |
| className | string | -- |
3. Usages
Common Command patterns and configurations.
Command Palette
Search for a command to run...
"use client";
import * as React from "react";
import {
Command,
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
} from "@/design-system/components/ui/command";
import { Button } from "@/components/ui/button";
import { HomeIcon, InboxIcon } from "lucide-react";
export function Example() {
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>
<HomeIcon />
<span>Home</span>
<CommandShortcut>⌘H</CommandShortcut>
</CommandItem>
<CommandItem>
<InboxIcon />
<span>Inbox</span>
<CommandShortcut>⌘I</CommandShortcut>
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</CommandDialog>
</div>
);
}