No results found.
Calendar
Search Emoji
Calculator
Profile⌘P
Billing⌘B
Settings⌘S
Installation
npx logic2b@next add commandUsage
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from "@/components/ui/command"
<Command>
<CommandInput placeholder="Type a command or search..." />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading="Suggestions">
<CommandItem>Calendar</CommandItem>
</CommandGroup>
</CommandList>
</Command>
CommandDialog
Use CommandDialog to render the command menu inside a modal (cmd+k style).
It depends on the dialog component.
import { CommandDialog, CommandInput, CommandList } from "@/components/ui/command"
<CommandDialog open={open} onOpenChange={setOpen}>
<CommandInput placeholder="Type a command or search..." />
<CommandList>...</CommandList>
</CommandDialog>
Usage notes
Built on cmdk. Props flow through to the underlying primitives.
Examples
With Icons
No results found.
Calendar
Search Emoji
Profile⌘P
Billing⌘B
Settings⌘S
Command Dialog
Render the menu inside a modal and toggle it with a keyboard shortcut.
Press
⌘J
or .Command Palette
Search for a command to run...
Accessibility
- Fully keyboard driven: the arrow keys move between items,
Enterruns the highlighted item, andHome/Endjump to the ends of the list. CommandInputis a combobox that owns the list viaaria-activedescendant, so focus stays in the input while items are announced as active.CommandSeparatoris decorative by default, which keeps it out of thelistboxchild-role contract while retaining its visual grouping.CommandDialogtraps focus, closes onEscape, and ships ansr-onlytitle and description so screen readers announce the palette on open.
Live playground
Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.
Generated JSX
<Command
className="w-full max-w-md border shadow-sm"
aria-label="Component commands"
>
<CommandInput
placeholder="Search components…"
aria-label="Search commands"
/>
<CommandList>
<CommandEmpty>No component found.</CommandEmpty>
<CommandGroup
heading="Components"
>
<CommandItem
value="button"
>Button</CommandItem>
<CommandItem
value="dialog"
>Dialog</CommandItem>
<CommandItem
value="tooltip"
>Tooltip</CommandItem>
</CommandGroup>
</CommandList>
</Command>No component found.
Button
Dialog
Tooltip
API reference
Generated from the public TypeScript exports in src/ui/command.tsx.
Command
ComponentProps: React.ComponentProps<typeof CommandPrimitive>CommandDialog
ComponentProps: React.ComponentProps<typeof Dialog> & { title?: string description?: string className?: string showCloseButton?: boolean }| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
title | string | No | "Command Palette" | — |
description | string | No | "Search for a command to run..." | — |
showCloseButton | boolean | No | true | — |
CommandInput
ComponentProps: React.ComponentProps<typeof CommandPrimitive.Input>CommandList
ComponentProps: React.ComponentProps<typeof CommandPrimitive.List>CommandEmpty
ComponentProps: React.ComponentProps<typeof CommandPrimitive.Empty>CommandGroup
ComponentProps: React.ComponentProps<typeof CommandPrimitive.Group>CommandItem
ComponentProps: React.ComponentProps<typeof CommandPrimitive.Item>CommandShortcut
ComponentProps: React.ComponentProps<"span">CommandSeparator
ComponentProps: React.ComponentProps<typeof CommandPrimitive.Separator>Accessibility contract
Machine-readable behavior and consumer responsibilities for command.
- Support
- Primitive-managed
- Pattern
- combobox with listbox
- cmdk
| Keys | Behavior |
|---|---|
| ArrowUp ArrowDown | Move through matching commands. |
| Enter | Run the active command. |
| Escape | Close the open surface and restore focus. |
Built-in semantics
- The input and list coordinate with combobox/listbox semantics and active descendant state.
Consumer responsibilities
- Give the dialog and input useful labels; commands must remain understandable without shortcut text.