Command
NavigationCommand palette (Cmd+K) with searchable list of actions and pages.
Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.
"use client";
import {
Command,
CommandInput,
CommandList,
CommandEmpty,
CommandGroup,
CommandItem,
CommandSeparator,
CommandShortcut,
} from "@dashboardpack/core/components/ui/command";
import { useState } from "react";
export default function CommandExample() {
const [action, setAction] = useState(
"Use arrow keys and Enter to select an action.",
);
return (
<div className="w-full max-w-md space-y-3">
<Command className="rounded-xl border shadow-sm">
<CommandInput placeholder="Search actions…" />
<CommandList>
<CommandEmpty>No actions found.</CommandEmpty>
<CommandGroup heading="Workspace">
<CommandItem onSelect={() => setAction("Create project")}>
Create project<CommandShortcut>⌘N</CommandShortcut>
</CommandItem>
<CommandItem onSelect={() => setAction("Invite member")}>
Invite member
</CommandItem>
</CommandGroup>
<CommandSeparator role="presentation" aria-hidden />
<CommandGroup heading="Settings">
<CommandItem onSelect={() => setAction("Open preferences")}>
Preferences
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
<p className="text-xs text-muted-foreground" role="status">
{action}
</p>
</div>
);
}Usage
Use the inline Command with input, list, groups, and items for searchable actions. CommandDialog is also exported for modal palettes; opening shortcuts must be implemented by the application.
import {
Command,
CommandInput,
CommandList,
CommandEmpty,
CommandGroup,
CommandItem,
CommandSeparator,
CommandShortcut,
} from "@dashboardpack/core/components/ui/command";Available in the included @dashboardpack/core package. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.
API reference
Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.
| Prop | Type / Default | Description |
|---|---|---|
| onSelect (CommandItem) | (value: string) => voidDefault: — | Invoked for the selected command. |
| value (CommandItem) | stringDefault: derived from text | Searchable unique value. |
| disabled (CommandItem) | booleanDefault: false | Exclude an unavailable command from selection. |
| shouldFilter (Command) | booleanDefault: true | Enable cmdk’s local filtering. |