Menu Button
A trigger that opens a menu of actions: row actions, account menus and secondary actions. The menu opens below the trigger at the inline start, the right in Arabic.
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 menuAlso works with shadcn:
npx shadcn@latest add @ritla/menuDependencies it brings
@base-ui/react@phosphor-icons/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 { DotsThreeVerticalIcon, PencilSimpleIcon } from "@phosphor-icons/react/ssr";import { IconButton } from "@/components/ui/icon-button";import { Menu, MenuContent, MenuItem, MenuTrigger } from "@/components/ui/menu";<Menu> <MenuTrigger render={<IconButton variant="outline" icon={DotsThreeVerticalIcon} label="Invoice actions" />} /> <MenuContent> <MenuItem leadingIcon={PencilSimpleIcon} onClick={edit}>Edit</MenuItem> <MenuItem onClick={duplicate}>Duplicate</MenuItem> </MenuContent></Menu>Examples
Split Button trigger
Figma's Button type: the Split Button's menu half opens the same menu, lined up with the whole button.
Avatar menu
Figma's Avatar menu type: the account avatar opens the account menu. The trigger is a round button named for what it opens (“Account menu”); the avatar inside it is decorative, so nothing is read twice.
Sections and dividers
MenuGroup with a MenuLabel names each section, with MenuSeparator between them. description adds a second line, MenuLinkItem navigates, and a disabled item stays visible with its reason.
Choices
State = Selected: MenuRadioGroup and MenuRadioItem for one choice, MenuCheckboxItem for several. The chosen row is brand/faint with a Check at the inline end (the left in Arabic) that never mirrors, and the menu stays open. subtitle is a short note beside the title, badge a count at the end.
A destructive action
State = Danger: danger turns the title, description and icon red. Put it last, in its own group, and let the title say what it does. trailingIcon is an icon at the end, here for what opens another site.
API reference
Menu
The root: holds the state (open, onOpenChange, disabled, modal).
| Prop | Type | Default | Description |
|---|---|---|---|
open / defaultOpen | boolean | None | Whether the menu is open (controlled or not). |
onOpenChange | (open: boolean) => void | None | Called when the menu opens or closes. |
disabled | boolean | false | Disables the trigger and the menu. |
MenuTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
render | ReactElement | None | The visible trigger: <IconButton … /> or <Button … />. It gets aria-haspopup and aria-expanded. |
MenuContent
| Prop | Type | Default | Description |
|---|---|---|---|
align | "start" | "center" | "end" | "start" | Alignment with the trigger; Figma uses the inline start. |
sideOffset | number | 12 | The gap below the trigger, in px. |
anchor | "trigger" | "parent" | "trigger" | What the menu lines up with; parent for the whole Split Button. |
MenuItem, MenuLinkItem, MenuSubmenuTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | None | The title (Figma Title). |
leadingIcon | IconComponent | None | Figma's Show leading: a 24px icon at the inline start. |
description | ReactNode | None | Figma's Show description: a second line under the title. |
subtitle | ReactNode | None | Figma's Show subtitle: a short note beside the title. |
badge | ReactNode | None | Figma's Show badge: a count or word at the inline end, not dimmed when disabled. Format numbers with formatNumber. |
trailingIcon | IconComponent | None | Figma's Show trailing: an icon at the inline end (MenuItem, MenuLinkItem). |
danger | boolean | false | State = Danger on MenuItem: an action that deletes or removes. |
onClick | (event) => void | None | MenuItem: called on selection; the menu then closes. |
href | string | None | MenuLinkItem: the link target. |
disabled | boolean | false | State = Disabled; stays visible and focusable but doesn't run. Put the reason in description. |
MenuRadioGroup, MenuRadioItem, MenuCheckboxItem
| Prop | Type | Default | Description |
|---|---|---|---|
value / defaultValue / onValueChange | string | None | MenuRadioGroup: the current choice. |
value | string | None | MenuRadioItem: this choice's value. |
checked / defaultChecked / onCheckedChange | boolean | None | MenuCheckboxItem: whether it's on. |
leadingIcon / subtitle / description / badge | … | None | As on MenuItem. |
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 |
|---|---|
| EnterSpaceArrowDown | On the trigger: opens the menu and focuses the first item. |
| ArrowDownArrowUp | Moves between items and wraps. A disabled item takes focus so its reason is read, but doesn't run. |
| ArrowRightArrowLeft | Opens and closes a submenu. Flips in Arabic: ArrowLeft opens. |
| Enter | Runs the focused item and closes the menu. |
| SpaceEnter | On a choice: picks or toggles it, and the menu stays open. |
| Escape | Closes the menu and returns focus to the trigger. |
ARIA
- The trigger carries
aria-haspopup="menu"andaria-expanded; the menu isrole="menu"withmenuitems. - An icon trigger needs a
labelthat says what the menu holds (“Invoice actions”), not “More”. MenuLabelnames its group, so screen readers announce the section.- Choices are
menuitemradioandmenuitemcheckboxwitharia-checked, so selection never rests on the color and the Check alone. The Check is hidden from screen readers.
Arabic and RTL notes
Mirrors
- The menu opens at the trigger's start (the right in Arabic); submenus open toward the inline end (the left).
- The submenu caret
CaretRightflips, and arrow keys follow the reading direction. - The menu takes the trigger's direction and language, even inside an Arabic island on an English page.
Does not mirror
DotsThreeVerticaland non-directional icons don't mirror.- The Check on a chosen row never mirrors, though it sits at the inline end.
- The Split Button caret points down, turns up while the menu is open, and never mirrors.
- Numerals
- Counts in second lines (“8 members”) use
formatNumber; identifiers (“INV-1042”) go in<bdi dir="ltr">and never change. - Arabic typography
- Titles are
label-14Medium, second lineslabel-12, section headersbody-14Semibold. Rows are 48px and grow for Arabic. - Mixed-direction text
- A Latin name at the end of an Arabic item (“تنزيل PDF”) renders correctly; in the middle, wrap it in
<bdi>.
Checks it passes
The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.
- 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)
- Clipped text: content wider than its box with overflow hidden and no ellipsis
- Fixed-pixel-width container whose Arabic text exceeds the space