Command Bar
Menus and commandsMITKeyboard-driven command bar (⌘K) with grouped actions, search, and shortcuts.
bun add @otfdashkit/ui
Preview
Command BarMenus and commands
Code
@otfdashkit/uiimport { CommandBar, CommandBarGroup, CommandBarItem, useCommandBar } from '@otfdashkit/ui'
function CommandBarDemo() {
const { open, setOpen } = useCommandBar()
return (
<div className="space-y-3">
<button className="text-sm underline" onClick={() => setOpen(true)}>Open Command Bar (⌘K)</button>
<CommandBar open={open} onOpenChange={setOpen}>
<CommandBarGroup heading="Navigation">
<CommandBarItem label="Go to Dashboard" shortcut="G D" onSelect={() => setOpen(false)} />
<CommandBarItem label="Go to Projects" shortcut="G P" onSelect={() => setOpen(false)} />
</CommandBarGroup>
<CommandBarGroup heading="Actions">
<CommandBarItem label="New Project" shortcut="⌘N" onSelect={() => setOpen(false)} />
<CommandBarItem label="Invite Team Member" onSelect={() => setOpen(false)} />
</CommandBarGroup>
</CommandBar>
</div>
)
}
export function Example() {
return (
<CommandBarDemo />
)
}
Free with the SDK. This block ships in @otfdashkit/ui under the MIT license.
Props
Props declared in the CommandBar source. Inherited HTML attributes are not listed.
| Prop | Type | Default | Description |
|---|---|---|---|
| childrenrequired | ReactNode | ||
| onOpenChangerequired | (v: boolean) => void | ||
| openrequired | boolean | ||
| onSearch | (q: string) => void | ||
| placeholder | string | 'Search commands...' |