Skip to main content

Module menu

Module menu 

Source
Expand description

The Material 3 Expressive menu: the node tree, its two color styles, and the anchored menu that presents them.

§Three layers

  1. items — the node vocabulary a caller composes (menu_entry, menu_selectable, menu_toggleable, MenuNode::Divider, menu_group, menu_submenu) and what an activation reports back (MenuSelection).
  2. panel — menu_panel, the reusable item-list surface: it renders the tree as a stack of elevated containers, runs the hover/press machine and owns the submenu chain. A dropdown or a button-group popup mounts this directly.
  3. menu — the panel inside crate::overlay::anchored, which is what turns it into a menu: trigger-relative placement, light dismiss, Escape, and the entrance/exit ramp.

§The host owns the ramp

crate::overlay::anchored composites the panel under its own fade and anchor-pivoted scale, so nothing here choreographs an entrance or an exit — and an app that wants the exit keeps the menu mounted and toggles MenuView::open rather than unmounting it (the kept-mounted pattern that host documents).

§Standard and vibrant

MenuColorStyle picks between the reference’s two container/content resolutions (m3e_menu_theme.dart:239-261): standard is a surfaceContainerLow surface with onSurface ink and a tertiaryContainer selection; vibrant makes the whole surface tertiaryContainer and promotes the selection to tertiary. Both resolve from plain ColorScheme roles — none of the nine crate::MaterialTokens extension roles applies here — which is the same role-partition line crate::divider draws.

Re-exports§

pub use items::MenuAction;
pub use items::MenuEntry;
pub use items::MenuGroup;
pub use items::MenuIcon;
pub use items::MenuNode;
pub use items::MenuSelectable;
pub use items::MenuSelection;
pub use items::MenuSubmenu;
pub use items::MenuToggleable;
pub use items::menu_entry;
pub use items::menu_group;
pub use items::menu_selectable;
pub use items::menu_submenu;
pub use items::menu_toggleable;
pub use items::partition_surfaces;
pub use panel::MenuPanelView;
pub use panel::MenuPanelWidget;
pub use panel::menu_panel;

Modules§

items
The menu content tree: the six node kinds a caller composes, and the surface partitioning the panel renders them through.
panel
The menu panel: the reusable item-list surface every Material menu family paints — the anchored menu here, and the dropdown/button-group popups built on top of it.

Structs§

MenuColors
One MenuColorStyle’s resolved roles (M3EMenuColors).
MenuView
A declarative Material menu: a menu_panel inside the anchored host. See menu.

Enums§

MenuColorStyle
Standard versus vibrant container/content mapping (enums/m3e_menu_color_style.dart).

Constants§

MENU_ICON_SIZE
A leading/trailing icon’s side length (iconSize: 24).
MENU_MAX_HEIGHT
The height past which a menu scrolls instead of growing (maxHeight: 320).
MENU_MAX_WIDTH
A menu surface’s maximum width (maxWidth: 280).
MENU_MIN_WIDTH
A menu surface’s minimum width, in logical px (minWidth: 112).
MENU_ROW_MIN_HEIGHT
A row’s minimum height (entryHeight: 48).

Functions§

menu
Build a menu over nodes, to be mounted while the app’s own open flag is set — or kept mounted with the flag handed to MenuView::open for an exit ramp (see crate::overlay::anchored for both mount contracts).