pub struct Badge { /* private fields */ }Expand description
A standalone or anchored Material badge. For anchored badges, include the badge’s information in the host’s accessible name.
Implementations§
Source§impl Badge
impl Badge
Sourcepub fn standalone() -> Badge
pub fn standalone() -> Badge
A small badge that participates in the surrounding layout.
Sourcepub fn standalone_label(text: impl Into<SharedString>) -> Badge
pub fn standalone_label(text: impl Into<SharedString>) -> Badge
A standalone text badge that participates in the surrounding layout.
Sourcepub fn standalone_count(count: usize, maximum: usize) -> Badge
pub fn standalone_count(count: usize, maximum: usize) -> Badge
A standalone capped numeric badge that participates in the surrounding layout.
Sourcepub fn dot(host: impl IntoElement) -> Badge
pub fn dot(host: impl IntoElement) -> Badge
Anchors a small badge to the host’s upper trailing edge.
pub fn label(host: impl IntoElement, text: impl Into<SharedString>) -> Badge
pub fn count(host: impl IntoElement, count: usize, maximum: usize) -> Badge
Sourcepub fn content(
self,
id: impl Into<ElementId>,
content: impl IntoElement,
) -> Badge
pub fn content( self, id: impl Into<ElementId>, content: impl IntoElement, ) -> Badge
Uses large badge styling with caller-supplied visual content.
Use a stable ID within the parent and keep the content noninteractive. The badge or its host supplies the accessible name.
Sourcepub fn tone(self, tone: SemanticTone) -> Badge
pub fn tone(self, tone: SemanticTone) -> Badge
Applies a Material 3 semantic tone shortcut.
SemanticTone::Default and SemanticTone::Danger use Error/OnError.
Explicit Self::color_role, Self::container_color, and
Self::content_color overrides take precedence.
Sourcepub fn color_role(self, container: ColorRole, content: ColorRole) -> Badge
pub fn color_role(self, container: ColorRole, content: ColorRole) -> Badge
Resolves container and content pigments from the window theme’s semantic color roles.
Takes precedence over Self::tone, and is overridden by explicit
Self::container_color and Self::content_color values.
Sourcepub fn container_color(self, color: impl Into<Hsla>) -> Badge
pub fn container_color(self, color: impl Into<Hsla>) -> Badge
Sets the background color, overriding Self::color_role and Self::tone.
Sourcepub fn content_color(self, color: impl Into<Hsla>) -> Badge
pub fn content_color(self, color: impl Into<Hsla>) -> Badge
Sets the inherited content color, overriding Self::color_role and Self::tone.
Sourcepub fn visible(self, visible: bool) -> Badge
pub fn visible(self, visible: bool) -> Badge
Controls whether the badge mark is rendered. When false, anchored badges render only
their host and standalone badges render empty. Defaults to true.
Sourcepub fn offset(self, offset: Point<Pixels>) -> Badge
pub fn offset(self, offset: Point<Pixels>) -> Badge
Shifts an anchored badge from its default upper-trailing anchor (x follows logical
direction; y shifts downward).
Sourcepub fn accessible_label(
self,
id: impl Into<ElementId>,
label: impl Into<SharedString>,
) -> Badge
pub fn accessible_label( self, id: impl Into<ElementId>, label: impl Into<SharedString>, ) -> Badge
Names a badge for assistive technology without adding a focus stop. Anchored badges normally use their host’s accessible name instead.
Trait Implementations§
Source§impl IntoElement for Badge
impl IntoElement for Badge
Source§type Element = ViewElement<Badge>
type Element = ViewElement<Badge>
Source§fn into_element(self) -> <Badge as IntoElement>::Element
fn into_element(self) -> <Badge as IntoElement>::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for Badge
impl RenderOnce for Badge
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for Badge
impl !Send for Badge
impl !Sync for Badge
impl !UnwindSafe for Badge
impl Forget for Badge
impl Freeze for Badge
impl Move for Badge
impl Unpin for Badge
impl UnsafeUnpin for Badge
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>
fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
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> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
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 moreSource§impl<T> MaterialElementExt for Twhere
T: IntoElement,
impl<T> MaterialElementExt for Twhere
T: IntoElement,
Source§fn badge_label(self, text: impl Into<SharedString>) -> Badge
fn badge_label(self, text: impl Into<SharedString>) -> Badge
Badge to this element’s upper trailing edge.Source§fn badge_count(self, count: usize, maximum: usize) -> Badge
fn badge_count(self, count: usize, maximum: usize) -> Badge
Badge to this element’s upper trailing edge.Source§fn tooltip(
self,
id: impl Into<ElementId>,
text: impl Into<SharedString>,
) -> Tooltip
fn tooltip( self, id: impl Into<ElementId>, text: impl Into<SharedString>, ) -> Tooltip
Tooltip.Menu.Menu
whose items are built lazily only while the menu is open.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<E> TestTextExt for Ewhere
E: IntoElement,
impl<E> TestTextExt for Ewhere
E: IntoElement,
Source§fn test_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_text(self, text: impl Into<SharedString>) -> Self::Element
test-support, records text each time the element paints.
Otherwise returns the element it builds.Source§fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
Self::test_text for an image’s alternative text, which
stands in for what the element draws.