UI Components
Command Menu
A βK command palette with fuzzy search, grouped items, keyboard navigation, and shortcut badges.
Quick Preview
or press βK
Installation
npm install cmdk
// Copy CommandMenu.tsx to your components/ui/ folder// src/components/ui/CommandMenu.tsx
Usage
import { CommandMenu, CommandItem } from '@/components/ui/CommandMenu'const items: CommandItem[] = [{id: 'settings',label: 'Settings',description: 'Manage your preferences',icon: <Settings size={14} />,shortcut: 'β,',group: 'Navigation',onSelect: () => router.push('/settings'),},]// Controlled usageconst [open, setOpen] = useState(false)<Button onClick={() => setOpen(true)}>Open</Button><CommandMenuitems={items}open={open}onOpenChange={setOpen}registerShortcut={false}/>// Or use registerShortcut to auto-bind βK / Ctrl+K<CommandMenu items={items} registerShortcut />
Prompt Preview
Copy a prompt that recreates this UI
Paste this into your AI coding assistant to generate code that closely matches the reference, including color, size, shape, typography, spacing, and polish.
Copy-ready AI prompt
Starts from the current visual reference and project constraints.
Tweak only product-specific copy or data after the first generation pass.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items* | CommandItem[] | - | Array of command items to display |
open | boolean | - | Controlled open state |
onOpenChange | (open: boolean) => void | - | Called when open state changes |
placeholder | string | "Type a commandβ¦" | Input placeholder text |
emptyMessage | string | "No results found." | Message shown when no results match |
registerShortcut | boolean | true | Binds βK / Ctrl+K to open the menu |
CommandItem Props
| Prop | Type | Default | Description |
|---|---|---|---|
id* | string | - | Unique identifier |
label* | string | - | Display label and search text |
onSelect* | () => void | - | Called when item is selected |
description | string | - | Secondary description text |
icon | React.ReactNode | - | Icon shown before label |
shortcut | string | - | Keyboard shortcut badge (display only) |
group | string | "General" | Group name for organizing items |