Design system / Molecules
Molecule / Selection
Command
Command composes searchable input, grouped items and selection through cmdk. CommandDialog adds modal disclosure. The caller supplies actions, remote results and execution behavior; shortcuts require separate registration.
Live example
Current component with fictional data. Example changes are not persisted.
No command selected.
Responsibility
Search input, results and selection form one searchable-choice contract. cmdk manages filtering and selection; CommandDialog supplies a modal container. Remote search, operation execution and global shortcuts require explicit caller integration.
Public contract
The table describes supported inputs, exported parts and caller responsibilities. A callback supplies a command, such as saving a draft. These notes are maintained manually; check current source types before integration.
| Prop / part | Type | Requirement | Responsibility |
|---|---|---|---|
| value / onValueChange / shouldFilter / filter | cmdk Root props | Delegated | Selection and filtering contract comes from cmdk. |
| value / onValueChange | cmdk Input props | Optional | Search input value; distinct from root selected value. |
| value / onSelect / disabled | cmdk Item props | Consumer choices | Execute chosen intent outside the primitive. |
| title / description / showCloseButton | CommandDialog additions | Defaults Command Palette / Search for a command to run... / true | Dialog props also pass through. |
| CommandShortcut | Native span props | Optional | Visual hint, not keyboard registration. |
API notes are curated documentation, not generated types. The source linked above is the current implementation; update these notes alongside API changes.
State and behavior
Identify which values the caller controls and which behavior the component or underlying primitive owns. A local example does not supply persistence, authorization or a complete product lifecycle.
cmdk handles local filtering/selection unless controlled. CommandDialog supplies Dialog wrapping. Global hotkeys, authorization, requests, pending and failures remain outside.
Dependencies
- cmdk Command primitives
- Dialog family for CommandDialog
- Lucide Search
- cn()
Token and styling contract
These notes identify theme roles, utilities and direct style values used by the source. Direct colors or timings are implementation exceptions, not recommendations to bypass the theme.
bg-popover / text-popover-foreground- Root surface.
bg-accent / text-accent-foreground- Selected command.
text-md / text-muted-foreground / border-b- Input and supporting group/shortcut roles.
Boundaries and limitations
- The existence of CommandDialog in this file does not establish product adoption.
- No global shortcut listener or operation lifecycle is installed by these wrappers.
Where to make a change
Change search/result anatomy in command.tsx; command definitions and execution remain consumer-owned. A Dialog change can affect CommandDialog. Keep filtering accessible and distinguish input text from selected item state.
Selected real uses
No product consumer is recorded in this entry's selected-use notes. The implementation and specimen establish availability, not adoption. These notes are not an exhaustive usage scan.
These traces describe selected uses, not every dependency. Repository-only paths are shown as references; only approved files have public source views.
Usage contract
import { Command, CommandInput, CommandList, CommandEmpty, CommandItem } from "@/components/ui/command";
<Command><CommandInput placeholder="Find an action" aria-label="Find an action" />
<CommandList><CommandEmpty>No matching actions</CommandEmpty>
<CommandItem value="details" onSelect={showDetails}>Details</CommandItem>
</CommandList>
</Command>Illustrative consumer bindings, not a self-contained product workflow. Live examples supply only local state or explicit fictional props.