npx shadcn@latest add https://sdk-components.thesqd.com/r/command.jsonimport { CommandMenu } from "@/components/ui/command";import { Calendar as CalendarIcon } from "@phosphor-icons/react/ssr";
import { CommandMenu } from "@/components/ui/command";
export function Example() {
return (
<CommandMenu
groups={[
{
heading: "Suggestions",
items: [
{ label: "Calendar", icon: <CalendarIcon weight="duotone" />, onSelect: () => {} },
],
},
]}
/>
);
}CommandMenu (single component — pass groups as data)
├── placeholder="Type a command…"
├── groups={[
│ {
│ heading?: ReactNode,
│ items: [
│ { label, icon?, shortcut?, onSelect?, disabled?, value? },
│ …
│ ],
│ },
│ …
│ ]}
├── emptyMessage="No results found."
├── asDialog (optional — wraps in CommandDialog modal)
├── open / onOpenChange (controlled when asDialog)
└── className
Need a custom shape — manual filtering, an empty state with full JSX, or
nested groups? The slot exports — Command, CommandInput, CommandList,
CommandEmpty, CommandGroup, CommandItem, CommandSeparator, CommandShortcut,
CommandDialog — are still exported as the escape hatch.Press ⌘K or click below.
No results found
Try searching for something else.
CommandMenu
| Prop | Type | Default | Description |
|---|---|---|---|
groups | CommandGroupSpec[] | — | List of groups to render. Each group has an optional heading and an `items` array. |
placeholder | string | "Type a command or search…" | Placeholder text rendered in the search input. |
emptyMessage | ReactNode | "No results found." | Rendered when the search filters every item out. Pass JSX for a richer empty layout. |
asDialog | boolean | false | Wrap the menu in `CommandDialog` so it opens as a centered modal triggered by `open` / `onOpenChange`. |
open | boolean | — | Controlled open state when `asDialog` is set. |
onOpenChange | (open: boolean) => void | — | Fires when the dialog opens or closes. |
dialogTitle | string | "Command Palette" | Accessible title used by `asDialog`. |
className | string | — | Override or extend the resolved classes. |
CommandItemSpec
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | — | Item content. Pass JSX for badges, secondary text, etc. |
icon | ReactNode | — | Leading icon — typically a lucide icon component. |
shortcut | ReactNode | — | Keyboard hint shown on the trailing edge of the row. |
onSelect | (value: string) => void | — | Fires when the item is chosen via mouse or keyboard. |
disabled | boolean | — | Skip the item in keyboard navigation and matching. |
value | string | — | Custom string used for filtering and for the `onSelect` callback. Defaults to the rendered text content. |