pub struct BadgeProps {
pub color: Color,
pub fill: BadgeFill,
pub pill: bool,
pub class: String,
pub onclick: Option<EventHandler<MouseEvent>>,
pub href: Option<String>,
pub target: Option<String>,
pub children: Element,
/* private fields */
}Expand description
Bootstrap Badge component.
§Bootstrap HTML → Dioxus
| HTML | Dioxus |
|---|---|
<span class="badge text-bg-primary">New</span> | Badge { color: Color::Primary, "New" } |
<span class="badge rounded-pill text-bg-danger">99+</span> | Badge { color: Color::Danger, pill: true, "99+" } |
<span class="badge bg-secondary">Alias</span> | Badge { color: Color::Secondary, fill: BadgeFill::Bg, "Alias" } |
<span class="badge bg-info-subtle text-info-emphasis">2 fields</span> | Badge { color: Color::Info, fill: BadgeFill::Subtle, "2 fields" } |
<span class="badge text-bg-secondary" role="button">Open</span> | `Badge { color: Color::Secondary, onclick: move |
rsx! {
Badge { color: Color::Primary, "New" }
Badge { color: Color::Danger, pill: true, "99+" }
Badge { color: Color::Info, fill: BadgeFill::Subtle, "2 fields" }
// Inside a heading
h1 { "Messages " Badge { color: Color::Info, "4" } }
}Fields§
§color: ColorBadge color variant.
fill: BadgeFillWhich Bootstrap colour idiom to paint the badge with. Defaults to
text-bg-<color>, so existing callers are unchanged.
pill: boolUse pill (rounded) style.
class: StringAdditional CSS classes.
onclick: Option<EventHandler<MouseEvent>>Click event handler.
href: Option<String>Render as a real <a class="badge" href=…> instead of a <span>.
Bootstrap documents badges used as links and buttons, and the anchor is not interchangeable with a span carrying a click handler: only the anchor is focusable, announced as a link, and openable in a new tab or copied from the context menu. A badge that navigates should be one.
target: Option<String>Anchor target (e.g. "_blank"). Only applies when href is set.
children: ElementChild elements.
Implementations§
Source§impl BadgeProps
impl BadgeProps
Sourcepub fn builder() -> BadgePropsBuilder<((), (), (), (), (), (), (), (), ())>
pub fn builder() -> BadgePropsBuilder<((), (), (), (), (), (), (), (), ())>
Create a builder for building BadgeProps.
On the builder, call .color(...)(optional), .fill(...)(optional), .pill(...)(optional), .class(...)(optional), .onclick(...)(optional), .href(...)(optional), .target(...)(optional), .attributes(...)(optional), .children(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of BadgeProps.
Trait Implementations§
Source§impl Clone for BadgeProps
impl Clone for BadgeProps
Source§fn clone(&self) -> BadgeProps
fn clone(&self) -> BadgeProps
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more