Loading component…
Loading component…
Search and run anything from one field – tool actions with logos and ⌘1–⌘5, everyday commands with icons
To reuse this local React demo, copy all files from the Code tab into the same folder, then import CommandMenu from ./command-menu.
import { CommandMenu, type CommandGroup } from "@/components/ui/command-menu";
export function Commands({ onClose }: { onClose: () => void }) {
return (
<CommandMenu
autoFocus
onClose={onClose}
onRun={(id, query) => (id === "ask" ? askAssistant(query) : runCommand(id))}
/>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| placeholder | string | "Type a command or search…" | Text in the empty field |
| onRun | (id: string, query?: string) => void | Called when a command runs; the assistant fallback sends "ask" and the typed text | |
| onClose | () => void | Runs on Esc in an empty field – close your dialog here | |
| autoFocus | boolean | Focus the field when the menu appears | |
| className | string | Extra class on the root |
Fills its container up to 600px; on phones shortcut keys and hints are left out
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"