0.1.0-rc.2

Menu Button

Menu buttons reveal a popup menu of actions when activated, such as overflow menus and contextual commands.

Try it

Usage

Compose the trigger, menu content, and action items explicitly. Control placement to avoid viewport clipping.

import {
  RuiMenuButton,
  RuiMenuButtonContent,
  RuiMenuButtonItem,
  RuiMenuButtonTrigger,
} from '@ecopages/radiant-ui/menu-button';
 
<RuiMenuButton placement="bottom-start">
  <RuiMenuButtonTrigger>Actions</RuiMenuButtonTrigger>
  <RuiMenuButtonContent>
    <RuiMenuButtonItem value="edit">Edit</RuiMenuButtonItem>
    <RuiMenuButtonItem value="delete">Delete</RuiMenuButtonItem>
  </RuiMenuButtonContent>
</RuiMenuButton>

Placement

Use bottom-start for left-aligned triggers. Flip to top-* when the button sits near the viewport bottom.

Theming

Menu Button surfaces map to semantic surface roles, never Tailwind palette steps:

PartCSS roles
Trigger (rui-menu-button__trigger)primary, on-primary (via rui-button--primary), --focus-ring
Menu surface (rui-menu-button__menu)background, border, shadow-overlay, rounded-container (via rui-popover)
Menu item (rui-menu-button__item)on-background; hover surface; --space-control-*

The trigger shares control geometry (--size-control-md, --space-control-x, --radius-button) with RuiButton. Override roles at the theme layer, not in component CSS.

API

RuiMenuButton is a custom element (<rui-menu-button>) with a composed light-DOM surface. Use the view helpers to compose the trigger and popup items, or use the convenience trigger / items props for generated content.

Attributes

AttributeTypeDefaultDescription
openbooleanfalseWhether the menu starts open.
placementtop · top-start · top-end · right · right-start · right-end · bottom · bottom-start · bottom-end · left · left-start · left-endbottom-startPlacement of the menu surface relative to its trigger.

Slots

SlotDescription
triggerLabel for the menu button.
(default)Menu items (role="menuitem"), typically buttons or anchors.

Events

EventDetailDescription
rui-change{ value: string }Emitted when a menu item is activated; value is the item's data-value or text.
rui-closeEmitted when the menu closes.

View helpers

ComponentRendersNotes
RuiMenuButton<rui-menu-button>Hosts the composed trigger and menu content. The convenience trigger + items props generate the same helpers.
RuiMenuButtonTriggerButtonTrigger control that opens the menu.
RuiMenuButtonContent<div role="menu">Popup surface containing menu items.
RuiMenuButtonItem<button role="menuitem">Selectable action inside the menu.

CSS classes

Public BEM classes on the composed light-DOM surface (documented via @cssclass):

ClassDescription
.rui-menu-buttonRoot wrapper around trigger and menu.
.rui-menu-button__triggerTrigger button (composes rui-button--primary).
.rui-menu-button__chevronChevron indicator.
.rui-menu-button__menuPopup menu surface (role="menu", rui-popover rui-floating).
.rui-menu-button__itemMenu item (role="menuitem", authored by the view helper).

Theme roles

PartCSS variables consumed
Trigger--primary, --on-primary, --focus-ring
Menu surface--background, --border, --shadow-overlay
Menu item--on-background, --surface (hover)
Geometry--size-control-*, --space-control-*, --radius-button

Accessibility

  • The trigger exposes aria-haspopup="menu" and aria-expanded when open.
  • Menu items are reachable by arrow keys and activate with Enter.
  • Return focus to the trigger when the menu closes.