Menubar

A visually persistent menu common in desktop applications.

Installation

pnpm dlx cubix@latest add menubar --base aria

Usage

Import
import {
  Menubar,
  MenubarContent,
  MenubarItem,
  MenubarMenu,
  MenubarSeparator,
  MenubarShortcut,
  MenubarTrigger,
} from "@/components/cubix/menubar"
Example
<Menubar>
  <MenubarMenu>
    <MenubarTrigger>File</MenubarTrigger>
    <MenubarContent>
      <MenubarItem>
        New Tab <MenubarShortcut>⌘T</MenubarShortcut>
      </MenubarItem>
      <MenubarItem>New Window</MenubarItem>
      <MenubarSeparator />
      <MenubarItem>Share</MenubarItem>
    </MenubarContent>
  </MenubarMenu>
</Menubar>

Composition

Use the following composition to build a Menubar:

 
Menubar
├── MenubarMenu
   ├── MenubarTrigger
   └── MenubarContent
       ├── MenubarItem
       ├── MenubarSeparator
       ├── MenubarCheckboxItem
       ├── MenubarRadioGroup
          └── MenubarRadioItem
       └── MenubarSub
           ├── MenubarSubTrigger
           └── MenubarSubContent
└── MenubarMenu
    ├── MenubarTrigger
    └── MenubarContent

Basic

Submenu

Nest menus with MenubarSub, MenubarSubTrigger, and MenubarSubContent.

Checkboxes

Radio

Sides

Use the side prop on MenubarContent to control placement.

API Reference

Menubar

PropTypeDefaultDescription
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).
childrenReact.ReactNode-One or more MenubarMenu elements.

MenubarTrigger

PropTypeDefaultDescription
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).
childrenReact.ReactNode-The trigger label shown in the menubar.

MenubarContent

PropTypeDefaultDescription
side"top" | "right" | "bottom" | "left""bottom"Preferred side of the trigger to render the menu on.
align"start" | "center" | "end""start"Alignment along the opposite axis of side.
sideOffsetnumber8Distance in pixels between the trigger and the menu.
alignOffsetnumber-4Offset in pixels along the alignment axis.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

MenubarItem

PropTypeDefaultDescription
insetboolean-Adds left padding to align with items that have indicators.
variant"default" | "destructive""default"Visual style of the menu item.
disabledboolean-Disables the menu item.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

MenubarCheckboxItem

PropTypeDefaultDescription
checkedboolean-Controlled checked state of the checkbox item.
insetboolean-Adds left padding for alignment.
disabledboolean-Disables the checkbox item.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

MenubarRadioGroup

PropTypeDefaultDescription
valuestring-Controlled value of the selected radio item.
defaultValuestring-Initial value when uncontrolled.
onValueChange(value: string) => void-Called when the selected value changes.