pub struct MenuItem { /* private fields */ }Expand description
An item in a Material menu. Callers retain command and selection state.
Implementations§
Source§impl MenuItem
impl MenuItem
Sourcepub fn new(id: impl Into<ElementId>, label: impl Into<SharedString>) -> MenuItem
pub fn new(id: impl Into<ElementId>, label: impl Into<SharedString>) -> MenuItem
Creates a standard action menu item with the given element ID and label.
Sourcepub fn group(
id: impl Into<ElementId>,
title: impl Into<SharedString>,
) -> MenuItem
pub fn group( id: impl Into<ElementId>, title: impl Into<SharedString>, ) -> MenuItem
Creates a non-interactive section heading row that is skipped by keyboard navigation.
Sourcepub fn divider(id: impl Into<ElementId>) -> MenuItem
pub fn divider(id: impl Into<ElementId>) -> MenuItem
Creates a non-interactive horizontal divider row inside a menu that is skipped by keyboard navigation.
Sourcepub fn section(
id: impl Into<ElementId>,
name: impl Into<SharedString>,
rows: impl IntoIterator<Item = MenuItem>,
) -> MenuItem
pub fn section( id: impl Into<ElementId>, name: impl Into<SharedString>, rows: impl IntoIterator<Item = MenuItem>, ) -> MenuItem
Creates a surfaced group with rows in the owning menu’s navigation order.
Sourcepub fn group_appearance(self, appearance: MenuSurfaceStyle) -> MenuItem
pub fn group_appearance(self, appearance: MenuSurfaceStyle) -> MenuItem
Sets the styled section’s surface appearance.
Sourcepub fn inactive_shape(self, shape: CornerShape) -> MenuItem
pub fn inactive_shape(self, shape: CornerShape) -> MenuItem
Sets the section shape used after the pointer leaves the section.
Sourcepub fn appearance(self, style: MenuItemStyle) -> MenuItem
pub fn appearance(self, style: MenuItemStyle) -> MenuItem
Configures the appearance of an action, checked or selected row.
Sourcepub fn tone(self, tone: SemanticTone) -> MenuItem
pub fn tone(self, tone: SemanticTone) -> MenuItem
Applies a Material 3 semantic tone to this row’s foreground and selected roles.
Explicit MenuItemStyle overrides and disabled styling still take precedence.
Sourcepub fn destructive(self) -> MenuItem
pub fn destructive(self) -> MenuItem
Shorthand for .tone(SemanticTone::Danger) on destructive menu commands.
Sourcepub fn shortcut(self, text: impl Into<SharedString>) -> MenuItem
pub fn shortcut(self, text: impl Into<SharedString>) -> MenuItem
Renders a desktop shortcut hint in the trailing slot using LabelSmall
and OnSurfaceVariant (or disabled color when disabled), unless an
explicit .trailing(...) overrides it.
Turns this row into a submenu trigger containing the given child items.
Sourcepub fn disabled(self, disabled: bool) -> MenuItem
pub fn disabled(self, disabled: bool) -> MenuItem
Marks the item as disabled, preventing activation and applying disabled styling.
Sourcepub fn checked(self, checked: bool) -> MenuItem
pub fn checked(self, checked: bool) -> MenuItem
Turns this row into a checkable menu item with the given caller-owned checked state.
Sourcepub fn selected(self, selected: bool) -> MenuItem
pub fn selected(self, selected: bool) -> MenuItem
Turns this row into a selectable menu item with the given caller-owned selected state.
Sourcepub fn content<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
pub fn content<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
Replaces the visible label while retaining the name passed to new.
Supply a repeatable factory so the content also appears during exit.
Sourcepub fn leading<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
pub fn leading<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
Supplies a decorative element at the logical start of an unmarked row.
Sourcepub fn supporting<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
pub fn supporting<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
Supplies additional visual content below the label.
Sourcepub fn trailing<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
pub fn trailing<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
Supplies decorative content at the logical end of the row.
Sourcepub fn selection_icon<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
pub fn selection_icon<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
Replaces the leading check mark of a checked or selected row.
Auto Trait Implementations§
impl !RefUnwindSafe for MenuItem
impl !Send for MenuItem
impl !Sync for MenuItem
impl !UnwindSafe for MenuItem
impl Forget for MenuItem
impl Freeze for MenuItem
impl Move for MenuItem
impl Unpin for MenuItem
impl UnsafeUnpin for MenuItem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more