Skip to content

Menu Button

Get Ritla UI

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

Open in Figma

Preview

Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.

PreviewCode
EnglishMirroredArabic
LTR →

Installation

  1. Add the component

    npx ritla add menu

    Also works with shadcn: npx shadcn@latest add @ritla/menu

  2. Dependencies it brings

    @base-ui/react@phosphor-icons/react

  3. Or 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

menu.tsx
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.

EnglishMirroredArabic
LTR →

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.

EnglishMirroredArabic
LTR →

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.

EnglishMirroredArabic
LTR →

Submenu

Multi level: “Move to” opens a submenu at the inline end. In Arabic it opens to the left; ArrowLeft opens it and ArrowRight closes it.

EnglishMirroredArabic
LTR →

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.

EnglishMirroredArabic
LTR →

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.

EnglishMirroredArabic
LTR →

API reference

Menu

The root: holds the state (open, onOpenChange, disabled, modal).

PropTypeDefaultDescription
open / defaultOpenbooleanNoneWhether the menu is open (controlled or not).
onOpenChange(open: boolean) => voidNoneCalled when the menu opens or closes.
disabledbooleanfalseDisables the trigger and the menu.

MenuTrigger

PropTypeDefaultDescription
renderReactElementNoneThe visible trigger: <IconButton … /> or <Button … />. It gets aria-haspopup and aria-expanded.

MenuContent

PropTypeDefaultDescription
align"start" | "center" | "end""start"Alignment with the trigger; Figma uses the inline start.
sideOffsetnumber12The 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

PropTypeDefaultDescription
childrenReactNodeNoneThe title (Figma Title).
leadingIconIconComponentNoneFigma's Show leading: a 24px icon at the inline start.
descriptionReactNodeNoneFigma's Show description: a second line under the title.
subtitleReactNodeNoneFigma's Show subtitle: a short note beside the title.
badgeReactNodeNoneFigma's Show badge: a count or word at the inline end, not dimmed when disabled. Format numbers with formatNumber.
trailingIconIconComponentNoneFigma's Show trailing: an icon at the inline end (MenuItem, MenuLinkItem).
dangerbooleanfalseState = Danger on MenuItem: an action that deletes or removes.
onClick(event) => voidNoneMenuItem: called on selection; the menu then closes.
hrefstringNoneMenuLinkItem: the link target.
disabledbooleanfalseState = Disabled; stays visible and focusable but doesn't run. Put the reason in description.

MenuRadioGroup, MenuRadioItem, MenuCheckboxItem

PropTypeDefaultDescription
value / defaultValue / onValueChangestringNoneMenuRadioGroup: the current choice.
valuestringNoneMenuRadioItem: this choice's value.
checked / defaultChecked / onCheckedChangebooleanNoneMenuCheckboxItem: whether it's on.
leadingIcon / subtitle / description / badge…NoneAs 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.

KeyAction
EnterSpaceArrowDownOn the trigger: opens the menu and focuses the first item.
ArrowDownArrowUpMoves between items and wraps. A disabled item takes focus so its reason is read, but doesn't run.
ArrowRightArrowLeftOpens and closes a submenu. Flips in Arabic: ArrowLeft opens.
EnterRuns the focused item and closes the menu.
SpaceEnterOn a choice: picks or toggles it, and the menu stays open.
EscapeCloses the menu and returns focus to the trigger.

ARIA

  • The trigger carries aria-haspopup="menu" and aria-expanded; the menu is role="menu" with menuitems.
  • An icon trigger needs a label that says what the menu holds (“Invoice actions”), not “More”.
  • MenuLabel names its group, so screen readers announce the section.
  • Choices are menuitemradio and menuitemcheckbox with aria-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 CaretRight flips, 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

  • DotsThreeVertical and 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-14 Medium, second lines label-12, section headers body-14 Semibold. 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.

  • R050Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
  • R051letter-spacing applied to Arabic text (breaks the connected script)
  • R042Clipped text: content wider than its box with overflow hidden and no ellipsis
  • R043Fixed-pixel-width container whose Arabic text exceeds the space