Menubar
WebA visually persistent menu common in desktop applications.
Installation
pnpm dlx cubix-ui@latest add menubarUsage
import {
Menubar,
MenubarContent,
MenubarItem,
MenubarMenu,
MenubarSeparator,
MenubarTrigger,
} from "@/components/cubix/menubar"
<Menubar dir="rtl" lang="fa">
<MenubarMenu>
<MenubarTrigger>پرونده</MenubarTrigger>
<MenubarContent>
<MenubarItem>زبانه جدید</MenubarItem>
<MenubarItem>پنجره جدید</MenubarItem>
<MenubarItem disabled>پنجره ناشناس</MenubarItem>
<MenubarSeparator />
<MenubarItem>چاپ</MenubarItem>
</MenubarContent>
</MenubarMenu>
<MenubarMenu>
<MenubarTrigger>ویرایش</MenubarTrigger>
<MenubarContent>
<MenubarItem>واگرد</MenubarItem>
<MenubarItem>بازگردانی</MenubarItem>
<MenubarSeparator />
<MenubarItem>برش</MenubarItem>
<MenubarItem>کپی</MenubarItem>
<MenubarItem>جایگذاری</MenubarItem>
</MenubarContent>
</MenubarMenu>
</Menubar>
Composition
Each MenubarMenu pairs a trigger with its content. The bar reads dir and lang from the closest ancestor, lays out triggers from the start edge (the right in RTL), and carries the locale into the portaled menus.
Menubar
├── MenubarMenu
│ ├── MenubarTrigger
│ └── MenubarContent
│ ├── MenubarItem
│ ├── MenubarSeparator
│ ├── MenubarCheckboxItem
│ ├── MenubarRadioGroup
│ │ └── MenubarRadioItem
│ └── MenubarSub
│ ├── MenubarSubTrigger
│ └── MenubarSubContent
└── MenubarMenu
├── MenubarTrigger
└── MenubarContentAccessibility
The bar is a menubar with roving focus between triggers. Each trigger exposes aria-haspopup and aria-expanded, each content is a menu, and checkbox and radio items announce their checked state.
| Key | Action |
|---|---|
| ArrowLeft / ArrowRight | Moves focus between menu triggers in reading direction. With a menu open, opens the neighboring menu instead. |
| Enter / Space / ArrowDown | On a trigger, opens its menu and focuses the first item. |
| ArrowDown / ArrowUp | Moves focus to the next or previous item. |
| Home / End | Moves focus to the first or last item. |
| Enter / Space | Activates the focused item. Checkbox and radio items toggle and keep the menu open. |
| Escape | Closes the menu and returns focus to its trigger. |
Examples
Basic
Split sections with MenubarSeparator. Set disabled on an item to lock it.
Icons
Place an icon before the label inside MenubarItem or MenubarSubTrigger. It sits at the start of the item (the right side in RTL).
Submenu
Nest menus with MenubarSub, MenubarSubTrigger, and MenubarSubContent. In RTL the submenu opens to the left and ArrowLeft opens it from the keyboard.
Checkboxes
Use MenubarCheckboxItem for options that turn on and off. The menu stays open while toggling.
Checkboxes with icons
Icons sit before the label; the checkbox control stays at the end of the item.
Radio
Use MenubarRadioGroup with MenubarRadioItem for exclusive choices.
Tick indicator
Set indicator="check" to show a plain tick instead of the Cubix Checkbox or Radio. The default is "control". On a radio group it applies to every item in the group.
Sides
Use the side prop on MenubarContent to control placement.
API Reference
Note: Parts render data-slot attributes (menubar, menubar-menu, menubar-trigger, menubar-content, menubar-item, menubar-checkbox-item, menubar-radio-group, menubar-radio-item, menubar-separator, menubar-sub-trigger, menubar-sub-content) for targeting in tests and parent selectors. Use the same props on Base UI, React Aria, and Radix.
Menubar
| Prop | Type | Default | Description |
|---|---|---|---|
| dir | "ltr" | "rtl" | - | Text direction. Portaled menus inherit this so RTL layout and alignment stay correct. |
| lang | string | - | Document language on the menubar and portaled content (e.g. "fa"). Enables IRANSans metrics and zero letter-spacing for Arab script. |
| 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 start 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. |
| defaultChecked | boolean | - | Initial checked state when uncontrolled. |
| indicator | "check" | "control" | - | What shows when checked: the Cubix Checkbox ("control", default) or a plain tick ("check"). |
| inset | boolean | - | Adds start 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. |
| indicator | "check" | "control" | - | Indicator for every item in the group: the Cubix Radio ("control", default) or a plain tick ("check"). An item's own indicator prop overrides it. |
| onValueChange | (value: string) => void | - | Called when the selected value changes. |
MenubarRadioItem
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | Value of this item. It is selected when it matches the group value. |
| indicator | "check" | "control" | - | Overrides the group indicator for this item: the Cubix Radio ("control") or a plain tick ("check"). |
| inset | boolean | - | Adds start padding for alignment. |
| disabled | boolean | - | Disables the radio item. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |