pub struct Badge { /* private fields */ }Expand description
Small status indicator badge styled like shadcn/ui
§Example
use armas_basic::components::{Badge, BadgeVariant};
fn ui(ui: &mut egui::Ui) {
// Default badge
Badge::new("New").show(ui);
// Secondary badge
Badge::new("Draft").variant(BadgeVariant::Secondary).show(ui);
// Destructive badge
Badge::new("Error").variant(BadgeVariant::Destructive).show(ui);
// Outline badge
Badge::new("Outline").variant(BadgeVariant::Outline).show(ui);
}Implementations§
Source§impl Badge
impl Badge
Sourcepub const fn variant(self, variant: BadgeVariant) -> Self
pub const fn variant(self, variant: BadgeVariant) -> Self
Set badge variant
Sourcepub const fn destructive(self) -> Self
pub const fn destructive(self) -> Self
Make this a destructive badge (shorthand)
Sourcepub const fn corner_radius(self, radius: f32) -> Self
pub const fn corner_radius(self, radius: f32) -> Self
Set corner radius
Sourcepub const fn vertical_padding(self, padding: f32) -> Self
pub const fn vertical_padding(self, padding: f32) -> Self
Set vertical padding
Sourcepub const fn selected(self, selected: bool) -> Self
pub const fn selected(self, selected: bool) -> Self
Set selected state (for interactive badge use)
Sourcepub fn show(self, ui: &mut Ui) -> BadgeResponse
pub fn show(self, ui: &mut Ui) -> BadgeResponse
Show the badge
Sourcepub fn show_ui(
self,
ui: &mut Ui,
content: impl FnOnce(&mut Ui, &ContentContext),
) -> BadgeResponse
pub fn show_ui( self, ui: &mut Ui, content: impl FnOnce(&mut Ui, &ContentContext), ) -> BadgeResponse
Show the badge with custom content instead of a text label.
The closure receives a &mut Ui (with override text color set) and a
ContentContext with the state-dependent color.
Use min_width to control the badge width.
Dot and removable features still work alongside custom content.
§Example
use armas_basic::components::Badge;
Badge::new("")
.min_width(60.0)
.show_ui(ui, |ui, ctx| {
// Render icon + text using ctx.color
ui.label("New");
});Trait Implementations§
Auto Trait Implementations§
impl Freeze for Badge
impl RefUnwindSafe for Badge
impl Send for Badge
impl Sync for Badge
impl Unpin for Badge
impl UnsafeUnpin for Badge
impl UnwindSafe for Badge
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
Mutably borrows from an owned value. Read more