Overlays
Command
A searchable list of commands on cmdk. Inline, or as a palette in a dialog with CommandDialog.
packages/design-system/components/ui/command.tsx
Examples
Command Palette
Search for a command to run...
Anatomy
- 01Command, rounded-4xl
- 02Input with a search icon
- 03List
- 04Groups with headings
- 05Items with shortcuts
- 06Empty state
Usage
import {
Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList,
} from "@repo/design-system/components/ui/command";
<CommandDialog open={open} onOpenChange={setOpen}>
<Command>
<CommandInput placeholder="Go to a page" />
<CommandList>
<CommandEmpty>Nothing found.</CommandEmpty>
<CommandGroup heading="Pages">
<CommandItem onSelect={() => router.push("/projects")}>Projects</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</CommandDialog>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| CommandDialog title / description | string | "Command Palette" | Screen reader only header for the dialog. |
| CommandDialog showCloseButton | boolean | false | The dialog's X. |
| CommandGroup heading | ReactNode | none | The group's label. |
| CommandItem onSelect | (value: string) => void | none | Called on click or Enter. |
| Command filter / shouldFilter | cmdk props | none | Custom scoring, or turn filtering off for server results. |
| className | string | none | Merged last with cn(). Use it for layout (width, margin), not to restyle the component. |
Guidance
Do
- Wrap the children of CommandDialog in a Command.
Don't
- Use it as a select. It is for doing, not choosing a value.