Glrk UI

Menubar

A wrapper for Base UI Menubar — multiple dropdown menus in a horizontal bar with plain, checkbox, and radio variants.

Default
Multiple menus
Checkbox
Indicator right (default)
Indicator left
With group labels
Radio
Controlled
Indicator left
With group labels

Installation

npx shadcn@latest add @glrk-ui/menubar

If you haven't set up the prerequisites yet, check out registry setup.

Usage

Basic

import { type menubaritemsT, MenubarWrapper } from "@/components/ui/menubar-wrapper"

const opts: menubaritemsT = [
  { key: "file", trigger: "File", items: ["New", "Open", "Save"] },
  { key: "edit", trigger: "Edit", items: ["Cut", "Copy", "Paste"] },
]

<MenubarWrapper items={opts} />

Checkbox

import { type menubarCheckboxitemsT, MenubarCheckboxWrapper } from "@/components/ui/menubar-wrapper"

const [checked, setChecked] = useState<allowedPrimitiveT[]>([])

const opts: menubarCheckboxitemsT = [
  { key: "view", trigger: "View", items: ["Sidebar", "Toolbar", "Status Bar"] },
]

<MenubarCheckboxWrapper
  items={opts}
  checked={checked}
  onCheckedChange={(v, c) =>
    setChecked(prev => (c ? [...prev, v] : prev.filter(x => x !== v)))
  }
/>

Radio

import { type menubarRadioitemsT, MenubarRadioWrapper } from "@/components/ui/menubar-wrapper"

const [val, setVal] = useState<allowedPrimitiveT>("Light")

const opts: menubarRadioitemsT = [
  { key: "theme", trigger: "Theme", items: ["Light", "Dark", "System"] },
]

<MenubarRadioWrapper items={opts} value={val} onValueChange={setVal} />

Indicator position

<MenubarCheckboxWrapper items={opts} indicatorAt="right" />
<MenubarRadioWrapper items={opts} indicatorAt="right" />

Per-menu overrides

Each menu item in the items array can override global props:

const opts: menubaritemsT = [
  {
    key: "file",
    trigger: "File",
    items: fileItems,
    triggerCls: "font-semibold",
    onSelect: v => handleFileAction(v),
    contentProps: { align: "start" },
  },
  {
    key: "edit",
    trigger: "Edit",
    items: editItems,
  },
]

Complex items (groups, submenus, separators)

const opts: menubaritemsT = [
  {
    key: "file",
    trigger: "File",
    items: [
      { label: "New", value: "new", shortcut: "⌘N" },
      "Open",
      "---",
      { group: "Recent", items: ["file1.txt", "file2.txt"] },
      { submenu: "Export", items: ["PDF", "HTML"] },
    ],
  },
]

Reference

Prop

Type

Prop

Type

Prop

Type