Menubar
The row of menus at the top of a desktop tool, like File and Edit. Each trigger opens a menu built from the Menu rows.
Ritla scan of this preview: 41 of 41 checks3 breakpointsScanned
Preview
Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.
Installation
Add the component
npx ritla add menubarAlso works with shadcn:
npx shadcn@latest add @ritla/menubarDependencies it brings
@base-ui/reactOr copy by hand
Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.
Usage
import { MenuItem, MenuSeparator } from "@/components/ui/menu";import { Menubar, MenubarContent, MenubarMenu, MenubarTrigger } from "@/components/ui/menubar";<Menubar> <MenubarMenu> <MenubarTrigger>File</MenubarTrigger> <MenubarContent> <MenuItem shortcut="⌘N" aria-keyshortcuts="Meta+N">New transfer</MenuItem> <MenuSeparator /> <MenuItem shortcut="⌘P" aria-keyshortcuts="Meta+P">Print</MenuItem> </MenubarContent> </MenubarMenu></Menubar>Examples
Menu rows
Every Menu row works here: icons, descriptions, section labels and disabled items. A disabled item stays and says why, so people learn where the command lives.
API reference
Menubar
| Prop | Type | Default | Description |
|---|---|---|---|
loopFocus | boolean | true | The arrow keys wrap from the last menu to the first. |
modal | boolean | true | While a menu is open, the page behind ignores the pointer. |
disabled | boolean | false | Disables the whole bar. |
MenubarTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | None | Figma's Label: the menu's name. |
MenubarContent
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | None | Menu rows: MenuItem, MenuSeparator, MenuGroup, submenus. |
align | "start" | "center" | "end" | "start" | Starts at the trigger's inline start (its right in Arabic). |
sideOffset / alignOffset | number | 9 / -5 | 4px under the bar; the first menu on its edge. |
MenuItem
| Prop | Type | Default | Description |
|---|---|---|---|
shortcut | ReactNode | None | The shortcut as printed (⌘N), display only. |
aria-keyshortcuts | string | None | The shortcut for screen readers (Meta+N). Your app handles the keys. |
Usage guidelines
A menubar groups a desktop tool's commands into named menus across the top. When to use it, how to arrange its menus and items, how it runs in Arabic, and the checks before handoff.
1. When to use it
A menubar belongs in desktop tools with many commands. Simpler apps use buttons and a single Menu.
Do
- Use it when there are more than ten commands in three or more groups.
- Keep the top-level names to one word.
Don't
- Add it to a marketing site.
- Mix it with a Navigation menu in the same header.
2. Menus and items
Each trigger opens a Menu: items, separators, submenus and shortcuts. Destructive items go last with the danger colour.
Do
- Group items with separators by task.
- Disable, do not hide, items that are unavailable now.
Don't
- Nest more than one submenu level.
- Put checkboxes and actions in the same group.
3. Arabic and RTL
Triggers run right to left; menus open under their trigger and align to its start edge. Shortcuts stay in Latin letters.
Before handoff
- Closed and open states placed in both directions.
- Keyboard behaviour noted for the developer.
- Phone fallback decided.
Accessibility
Keyboard
Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.
| Key | Action |
|---|---|
| ArrowRightArrowLeft | Between menus; with a menu open, opens the next one. |
| ArrowDownEnterSpace | Opens the menu and moves to its first item. |
| ArrowUpArrowDown | Between the open menu's items. |
| Esc | Closes the menu and returns focus to its trigger. |
ARIA
- The bar is
role="menubar"; each trigger is amenuitemwitharia-haspopupandaria-expanded. - Only one trigger is in the Tab order; the arrow keys move between the rest.
- Shortcut symbols are hidden from screen readers;
aria-keyshortcutssays them in words. - Triggers are 28px tall with a 48px hit area vertically only, so one never takes its neighbour's clicks.
Arabic and RTL notes
Mirrors
- The first menu sits on the right, and menus line up with their trigger's right edge.
- ArrowLeft moves to the next menu in Arabic.
- Shortcuts sit at the row's end, on the left; submenus open to the left.
Does not mirror
- Shortcuts read left to right (
⇧⌘E). - Non-directional icons (files, lock) don't mirror.
- Numerals
- Numbers in items follow the numerals setting; shortcut keys stay as printed on the keyboard.
- Arabic typography
- Triggers
label-14Medium, items as the Menu rows, shortcutslabel-12Medium. - Mixed-direction text
- The shortcut is
<kbd dir="ltr">, so ⇧⌘E keeps its order inside an Arabic row. Small screens: move the commands into a More menu or a Drawer.
Do
- The RTL variant, with submenus opening toward the inline end.
- Write the shortcut the same way in both languages: Ctrl+S.
Don't
- Mirror the shortcut glyphs.
- Translate menu names that are product names.
Checks it passes
The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.
- Clipped text: content wider than its box with overflow hidden and no ellipsis
- Fixed-pixel-width container whose Arabic text exceeds the space
- Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
- letter-spacing applied to Arabic text (breaks the connected script)