Skip to content

Command Bar

Menus and commandsMIT
View in Storybook

Keyboard-driven command bar (⌘K) with grouped actions, search, and shortcuts.

bun add @otfdashkit/ui

Preview

Command Bar

Code

import { 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.

PropTypeDefaultDescription
childrenrequiredReactNode
onOpenChangerequired(v: boolean) => void
openrequiredboolean
onSearch(q: string) => void
placeholderstring'Search commands...'