pub struct ToastProps {
pub show: Signal<bool>,
pub title: String,
pub subtitle: String,
pub show_close: bool,
pub color: Option<Color>,
pub on_dismiss: Option<EventHandler<()>>,
pub class: String,
pub children: Element,
}Expand description
Bootstrap Toast notification — signal-driven, no JavaScript.
§Bootstrap HTML → Dioxus
<!-- Bootstrap HTML (requires JavaScript) -->
<div class="toast show">
<div class="toast-header">
<strong class="me-auto">Notification</strong>
<small>just now</small>
<button class="btn-close" data-bs-dismiss="toast"></button>
</div>
<div class="toast-body">You have a new message.</div>
</div>// Dioxus equivalent
let show = use_signal(|| true);
rsx! {
ToastContainer { position: ToastPosition::TopEnd,
Toast { show: show, title: "Notification", subtitle: "just now",
"You have a new message."
}
}
}§Headerless Mode
Omit title and set show_close: true to render a headerless toast with
a side-aligned close button (Bootstrap 5.3 d-flex pattern):
rsx! {
Toast { show: signal, show_close: true, color: Color::Primary,
"Body-only toast with close button."
}
}§Props
show—Signal<bool>controlling visibilitytitle— toast header title (omit for headerless mode)subtitle— small text in header (e.g., “just now”)color— background color variantshow_close— show close button (default: true)on_dismiss— callback when the toast is dismissed
Fields§
§show: Signal<bool>Signal controlling visibility.
title: StringToast title (shown in header).
subtitle: StringSmall text in header (e.g., “just now”, “2 mins ago”).
show_close: boolShow close button.
color: Option<Color>Toast color variant (applied as bg class).
on_dismiss: Option<EventHandler<()>>Callback when the toast is dismissed.
class: StringAdditional CSS classes.
children: ElementToast body content.
Implementations§
Source§impl ToastProps
impl ToastProps
Sourcepub fn builder() -> ToastPropsBuilder<((), (), (), (), (), (), (), ())>
pub fn builder() -> ToastPropsBuilder<((), (), (), (), (), (), (), ())>
Create a builder for building ToastProps.
On the builder, call .show(...), .title(...)(optional), .subtitle(...)(optional), .show_close(...)(optional), .color(...)(optional), .on_dismiss(...)(optional), .class(...)(optional), .children(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of ToastProps.
Trait Implementations§
Source§impl Clone for ToastProps
impl Clone for ToastProps
Source§fn clone(&self) -> ToastProps
fn clone(&self) -> ToastProps
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more