Hold the shortcut to squeeze the keys, then release to open.
Command menu
A ⌘K command palette and keyboard shortcut with squeeze effect.
Installation
npx shadcn@latest add qubydev/bunui/command-menuHow to use
import { CommandMenu } from "@/components/ui/command-menu"import { Home, Settings, User } from "lucide-react"const items = [{ id: "home", label: "Go to Dashboard", icon: <Home />, group: "Navigation" },{ id: "profile", label: "Open Profile", icon: <User />, group: "Navigation" },{ id: "settings", label: "Settings", icon: <Settings />, shortcut: "⌘," },]export function Demo() {return <CommandMenu items={items} onSelect={(item) => console.log(item.id)} />}
Props
Options you can pass to customize this component.
items*CommandMenuItem[]Commands to render. Each item has an id, label, and optional icon, description, shortcut, keywords, group, and onSelect.
openbooleanOpen state for controlled usage. Leave it out to let the component manage itself.
defaultOpenbooleanInitial open state when the component is uncontrolled.
onOpenChange(open: boolean) => voidCalled whenever the open state changes.
onSelect(item: CommandMenuItem) => voidCalled with the chosen item, in addition to the item's own onSelect.
hotkeystringLetter pressed with the modifier (⌘ on macOS, Ctrl elsewhere) to open the menu.
placeholderstringPlaceholder shown inside the search input.
triggerPlaceholderstringLabel shown inside the trigger before the shortcut chips.
emptyMessagestringMessage shown when no item matches the query.
showTriggerbooleanRenders the built-in search-style trigger. Set false to open via the hotkey only.
classNamestringExtra classes merged onto the trigger.
Dependencies
License & Usage
- •Free to use and modify in personal and commercial projects.
- •Attribution to Bun UI is appreciated when using a component.
- •Please do not resell the components as your own kit.