Menubar
A visually persistent menu common in desktop applications.
Installation
pnpm dlx cubix@latest add menubarUsage
import {
Menubar,
MenubarContent,
MenubarItem,
MenubarMenu,
MenubarSeparator,
MenubarShortcut,
MenubarTrigger,
} from "@/components/cubix/menubar"<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
└── MenubarContentBasic
Submenu
Nest menus with MenubarSub, MenubarSubTrigger, and MenubarSubContent.
Checkboxes
Radio
Sides
Use the side prop on MenubarContent to control placement.
API Reference
Menubar
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
| children | React.ReactNode | - | One or more MenubarMenu elements. |
MenubarTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
| children | React.ReactNode | - | The trigger label shown in the menubar. |
MenubarContent
| Prop | Type | Default | Description |
|---|---|---|---|
| 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. |
| sideOffset | number | 8 | Distance in pixels between the trigger and the menu. |
| alignOffset | number | -4 | Offset in pixels along the alignment axis. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
MenubarItem
| Prop | Type | Default | Description |
|---|---|---|---|
| inset | boolean | - | Adds left padding to align with items that have indicators. |
| variant | "default" | "destructive" | "default" | Visual style of the menu item. |
| disabled | boolean | - | Disables the menu item. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
MenubarCheckboxItem
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean | - | Controlled checked state of the checkbox item. |
| inset | boolean | - | Adds left padding for alignment. |
| disabled | boolean | - | Disables the checkbox item. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
MenubarRadioGroup
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | Controlled value of the selected radio item. |
| defaultValue | string | - | Initial value when uncontrolled. |
| onValueChange | (value: string) => void | - | Called when the selected value changes. |