Skip to main content

rc-menubar

Menubar coordinator for rc-menu-button children with roving tabindex and submenu handoff, following the WAI-ARIA Menubar pattern.

Package
@rcarls/rc-menubar
Element
<rc-menubar>
Native dependency
Consumer supplies menu buttons and menus
State model
Roving focus and submenu state
Main events
None

Installation

npm install @rcarls/rc-menubar
import '@rcarls/rc-menubar/define';

Live demo

Theming

The default demo mode shows the component without a package theme. Use the shared preview controls on this page to compare inherited, light, and dark color schemes or to apply the optional Material theme only inside the demo frames.

rc-menubar owns the menubar surface and maps --rc-menubar-item-* variables onto each child rc-menu-button trigger. This keeps top-level menubar items flat while standalone menu buttons can keep their own button-like defaults.

API

Properties

PropertyMarkupTypeDefaultDescription
labellabelstring'Menu'Accessible label for the `role="menubar"` element.
orientationorientation'horizontal' | 'vertical''horizontal'Orientation of the menubar, controls which arrow keys move between items.
$itemsJS property onlyHTMLElement[]Not specifiedAll slotted trigger elements in DOM order.
$menuButtonsJS property onlyRCMenuButton[]Not specifiedAll slotted `rc-menu-button` children in DOM order.
$firstItemJS property onlyHTMLElement | undefinedNot specifiedFirst trigger element in the menubar.
$lastItemJS property onlyHTMLElement | undefinedNot specifiedLast trigger element in the menubar.
$nextItemJS property onlyHTMLElement | undefinedNot specifiedTrigger after `_$lastFocused`, wrapping around to the first.
$previousItemJS property onlyHTMLElement | undefinedNot specifiedTrigger before `_$lastFocused`, wrapping around to the last.

Methods

MethodDescription
focusItem(item?: HTMLElement | null)Moves focus to a trigger element.
closeActiveMenu()Closes the currently open child menu without returning focus to its trigger.

Events

No custom events are documented in the custom elements manifest.

Slots

NameDescription
defaultTakes rc-menu-button elements to display in the menubar

CSS Custom Properties

PropertyDefaultDescription
--rc-menubar-gapvar(--rc-control-gap)Gap between menu buttons
--rc-menubar-padding-inlinevar(--rc-control-padding-inline)Inline-axis padding
--rc-menubar-padding-blockvar(--rc-control-padding-block)Block-axis padding
--rc-menubar-bordervar(--rc-border)Root container border
--rc-menubar-radiusvar(--rc-control-radius)Root container border radius
--rc-menubar-backgroundCanvasRoot container background
--rc-menubar-colorCanvasTextRoot container text color
--rc-menubar-item-block-size2.25emMinimum block size for child menu-button triggers
--rc-menubar-item-padding-block0.25emChild trigger block-axis padding
--rc-menubar-item-padding-inline0.75emChild trigger inline-axis padding
--rc-menubar-item-gapvar(--rc-item-gap)Gap between flex children inside child triggers
--rc-menubar-item-border1px solid transparentChild trigger border
--rc-menubar-item-radiusvar(--rc-control-radius)Child trigger border radius
--rc-menubar-item-backgroundtransparentChild trigger background
--rc-menubar-item-colorinheritChild trigger text color
--rc-menubar-item-transitionNot specifiedCSS transition applied to child triggers
--rc-menubar-item-hover-backgroundcolor-mix(in srgb, Highlight 8%, transparent)Child trigger hover background
--rc-menubar-item-hover-colorinheritChild trigger hover text color
--rc-menubar-item-hover-border-colortransparentChild trigger hover border color
--rc-menubar-item-open-backgroundcolor-mix(in srgb, Highlight 12%, transparent)Child trigger background when its menu is open
--rc-menubar-item-open-colorinheritChild trigger text color when its menu is open
--rc-menubar-item-open-border-colortransparentChild trigger border color when its menu is open

CSS Parts

PartDescription
rootThe root container element