pub struct Badge { /* private fields */ }Expand description
A non-interactive status label with optional count and leading mark.
It defaults to accent/soft styling. Empty labels and a count of zero remain visible values; repeated leading builder calls replace the prior mark.
§Examples
use ailloli_ui_widgets::controls::{Badge, BadgeTone};
let badge = Badge::new("Inbox").tone(BadgeTone::Info).count(3);
let _ = badge;Implementations§
Source§impl Badge
impl Badge
Sourcepub fn width(self, value: impl Into<Length>) -> Self
pub fn width(self, value: impl Into<Length>) -> Self
Sets preferred width from a logical-pixel or length value.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).width(24.0);
let _ = widget;Sourcepub fn height(self, value: impl Into<Length>) -> Self
pub fn height(self, value: impl Into<Length>) -> Self
Sets preferred height from a logical-pixel or length value.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).height(24.0);
let _ = widget;Sourcepub fn min_width(self, value: impl Into<Length>) -> Self
pub fn min_width(self, value: impl Into<Length>) -> Self
Sets the minimum width bound.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).min_width(12.0);
let _ = widget;Sourcepub fn max_width(self, value: impl Into<Length>) -> Self
pub fn max_width(self, value: impl Into<Length>) -> Self
Sets the maximum width bound.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).max_width(32.0);
let _ = widget;Sourcepub fn min_height(self, value: impl Into<Length>) -> Self
pub fn min_height(self, value: impl Into<Length>) -> Self
Sets the minimum height bound.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).min_height(12.0);
let _ = widget;Sourcepub fn max_height(self, value: impl Into<Length>) -> Self
pub fn max_height(self, value: impl Into<Length>) -> Self
Sets the maximum height bound.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).max_height(32.0);
let _ = widget;Sourcepub fn fill(self) -> Self
pub fn fill(self) -> Self
Sets both preferred axes to parent fill.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).fill();
let _ = widget;Sourcepub fn fill_width(self) -> Self
pub fn fill_width(self) -> Self
Sets preferred width to parent fill.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).fill_width();
let _ = widget;Sourcepub fn fill_height(self) -> Self
pub fn fill_height(self) -> Self
Sets preferred height to parent fill.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).fill_height();
let _ = widget;Sourcepub fn margin(self, value: f32) -> Self
pub fn margin(self, value: f32) -> Self
Sets uniform outer margin in logical pixels.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).margin(4.0);
let _ = widget;Sourcepub fn padding(self, value: f32) -> Self
pub fn padding(self, value: f32) -> Self
Sets uniform inner padding in logical pixels.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).padding(4.0);
let _ = widget;Sourcepub fn flex_grow(self) -> Self
pub fn flex_grow(self) -> Self
Sets flex-grow weight to one.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).flex_grow();
let _ = widget;Sourcepub fn flex_grow_by(self, value: f32) -> Self
pub fn flex_grow_by(self, value: f32) -> Self
Sets a dimensionless flex-grow weight.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).flex_grow_by(2.0);
let _ = widget;Sourcepub fn flex_shrink(self, value: f32) -> Self
pub fn flex_shrink(self, value: f32) -> Self
Sets a dimensionless flex-shrink weight.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).flex_shrink(1.0);
let _ = widget;Sourcepub fn flex_basis(self, value: impl Into<Length>) -> Self
pub fn flex_basis(self, value: impl Into<Length>) -> Self
Sets the preferred main-axis flex basis.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).flex_basis(20.0);
let _ = widget;Sourcepub fn align_self(self, value: AlignItems) -> Self
pub fn align_self(self, value: AlignItems) -> Self
Overrides cross-axis alignment for this flex item.
§Examples
use ailloli_ui_core::{style::AlignItems, IconId};
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).align_self(AlignItems::Center);
let _ = widget;Source§impl Badge
impl Badge
Sourcepub fn new(label: impl Into<String>) -> Self
pub fn new(label: impl Into<String>) -> Self
Creates an accent/soft label with no count or leading mark.
§Examples
use ailloli_ui_widgets::controls::Badge;
let badge = Badge::new("Beta");
let _ = badge;Sourcepub fn dot(label: impl Into<String>) -> Self
pub fn dot(label: impl Into<String>) -> Self
Creates a badge with a leading tone-colored dot.
§Examples
use ailloli_ui_widgets::controls::Badge;
let badge = Badge::dot("Online");
let _ = badge;Sourcepub fn tone(self, tone: BadgeTone) -> Self
pub fn tone(self, tone: BadgeTone) -> Self
Selects a tone and regenerates style from the default theme.
This replaces any custom style previously supplied with
Self::badge_style.
§Examples
use ailloli_ui_widgets::controls::{Badge, BadgeTone};
let badge = Badge::new("Failed").tone(BadgeTone::Danger);
let _ = badge;Sourcepub fn variant(self, variant: BadgeVariant) -> Self
pub fn variant(self, variant: BadgeVariant) -> Self
Selects a variant and regenerates style from the default theme.
§Examples
use ailloli_ui_widgets::controls::{Badge, BadgeVariant};
let badge = Badge::new("Stable").variant(BadgeVariant::Filled);
let _ = badge;Sourcepub fn badge_style(self, style: BadgeStyle) -> Self
pub fn badge_style(self, style: BadgeStyle) -> Self
Replaces the resolved style without changing stored tone/variant.
A later Self::tone or Self::variant call regenerates the style.
§Examples
use ailloli_ui_widgets::controls::{Badge, BadgeStyle};
let badge = Badge::new("Custom").badge_style(BadgeStyle::default());
let _ = badge;Sourcepub fn count(self, count: u32) -> Self
pub fn count(self, count: u32) -> Self
Sets the unsigned decimal count rendered after the label.
Zero is rendered as 0; a later call replaces the previous count.
§Examples
use ailloli_ui_widgets::controls::Badge;
let badge = Badge::new("Alerts").count(0);
let _ = badge;Sourcepub fn leading_icon(self, icon: IconId) -> Self
pub fn leading_icon(self, icon: IconId) -> Self
Sets a leading icon, replacing any dot or previous icon.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::controls::Badge;
let badge = Badge::new("History").leading_icon(IconId::History);
let _ = badge;Sourcepub fn leading_dot(self) -> Self
pub fn leading_dot(self) -> Self
Sets a leading dot, replacing any icon.
§Examples
use ailloli_ui_widgets::controls::Badge;
let badge = Badge::new("Live").leading_dot();
let _ = badge;