pub struct AlertProps {
pub color: Color,
pub heading: String,
pub dismissible: bool,
pub on_dismiss: Option<EventHandler<()>>,
pub class: String,
pub children: Element,
/* private fields */
}Expand description
Bootstrap Alert component.
§Bootstrap HTML → Dioxus
| HTML | Dioxus |
|---|---|
<div class="alert alert-success"> | Alert { color: Color::Success, "Text" } |
<div class="alert alert-danger alert-dismissible"> | Alert { color: Color::Danger, dismissible: true, "Text" } |
rsx! {
Alert { color: Color::Success, "Operation completed!" }
Alert { color: Color::Danger, dismissible: true,
strong { "Error! " }
"Something went wrong."
}
// With dismiss callback:
Alert { color: Color::Warning, dismissible: true,
on_dismiss: move |_| { /* clear error state */ },
"Dismissible with callback."
}
}Fields§
§color: ColorAlert color variant.
heading: StringOptional heading, rendered as Bootstrap’s .alert-heading above the
body. Bootstrap documents this class for exactly this case — a titled
callout whose heading inherits the alert’s colour — so expressing it is
the crate’s job. Empty (the default) renders no heading at all, leaving
a flat-text alert byte-identical to what it was before.
dismissible: boolShow a dismiss button. When clicked, the alert hides itself.
on_dismiss: Option<EventHandler<()>>Callback when the dismiss button is clicked. Use this to clear external state.
class: StringAdditional CSS classes.
children: ElementChild elements.
Implementations§
Source§impl AlertProps
impl AlertProps
Sourcepub fn builder() -> AlertPropsBuilder<((), (), (), (), (), (), ())>
pub fn builder() -> AlertPropsBuilder<((), (), (), (), (), (), ())>
Create a builder for building AlertProps.
On the builder, call .color(...)(optional), .heading(...)(optional), .dismissible(...)(optional), .on_dismiss(...)(optional), .class(...)(optional), .attributes(...)(optional), .children(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of AlertProps.
Trait Implementations§
Source§impl Clone for AlertProps
impl Clone for AlertProps
Source§fn clone(&self) -> AlertProps
fn clone(&self) -> AlertProps
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more