pub enum MenuItem {
SectionLabel(SharedString),
Separator,
#[non_exhaustive] Item {
key: SharedString,
label: SharedString,
shortcut: Option<SharedString>,
icon: Option<&'static str>,
is_danger: bool,
description: Option<SharedString>,
submenu: Vec<MenuItem>,
is_interactive: bool,
},
}Expand description
One entry of a dropdown menu.
Variants§
SectionLabel(SharedString)
Section caption (<MenuSection> title).
Separator
A divider row between items.
#[non_exhaustive]Item
A menu row.
#[non_exhaustive]: build one through MenuItem::new and its
builders, which cover every field, so a later row capability is an
additive change rather than a break for literal construction.
Fields
This variant is marked as non-exhaustive
key: SharedStringStable key identifying the item.
label: SharedStringVisible text of the item.
shortcut: Option<SharedString>Optional shortcut hint shown on the row.
description: Option<SharedString>Description inside a Dropdown.Item — v3’s “With Descriptions”.
Dropdown.SubmenuTrigger — the rows this item opens. The row grows a
trailing indicator and the panel appears beside it.
is_interactive: boolWhether the row’s own content owns the interaction, in place of the
row acting as one button. See MenuItem::is_interactive.
Implementations§
Source§impl MenuItem
impl MenuItem
Sourcepub fn new(key: impl Into<SharedString>, label: impl Into<SharedString>) -> Self
pub fn new(key: impl Into<SharedString>, label: impl Into<SharedString>) -> Self
Creates a menu item from a key and a label.
Sourcepub fn description(self, text: impl Into<SharedString>) -> Self
pub fn description(self, text: impl Into<SharedString>) -> Self
Description — the second line v3 composes inside an item.
Sourcepub fn is_interactive(self, interactive: bool) -> Self
pub fn is_interactive(self, interactive: bool) -> Self
Hands the row’s interaction to the element Menu::item_content draws
for it, in place of the row behaving as one button.
HeroUI composes rows that carry an inline secondary control — a small
select, a stepper — on the trailing edge, where pressing that control
must not also pick the row and close the menu. A stock row attaches an
unconditional click that reports the action and dismisses, plus the
[data-pressed] 98% scale over the whole row, so a hosted control is
unusable inside one. Setting this drops all three, and Enter and Space
stop activating the row, leaving the hosted element to answer the
pointer and the keyboard itself.
What it keeps: the row stays a keyboard stop with its hover fill,
highlight and focus ring, and it keeps its menuitem role and
accessible name, so arrowing through the menu is unchanged.
Nothing else is needed to host a popup-opening control such as a
crate::select::Select. Such a control registers its own panel on the
shared overlay stack, which makes it topmost, and the menu’s
outside-press and Escape dismissals are already gated on being topmost —
so they stand down for as long as the inner panel is open.
Ignored together with MenuItem::submenu: a submenu trigger already
opts out of the row click, and its flyout is the interaction.
Dropdown.SubmenuTrigger — the rows this item opens.
Sourcepub fn shortcut(self, s: impl Into<SharedString>) -> Self
pub fn shortcut(self, s: impl Into<SharedString>) -> Self
Sets the shortcut hint shown on the row.
Auto Trait Implementations§
impl Freeze for MenuItem
impl RefUnwindSafe for MenuItem
impl Send for MenuItem
impl Sync for MenuItem
impl Unpin for MenuItem
impl UnsafeUnpin for MenuItem
impl UnwindSafe 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