9 unstable releases (3 breaking)
0.4.0 | Sep 9, 2024 |
---|---|
0.3.0 | Dec 12, 2023 |
0.2.0 | Mar 7, 2023 |
0.1.5 | May 15, 2022 |
0.1.3 | Mar 10, 2022 |
#284 in GUI
39KB
254 lines
Dioxus Toast
use dioxus::prelude::*;
use dioxus_toast::{ToastInfo, ToastManager};
fn main() {
launch(app)
}
fn app() -> Element {
std::panic::set_hook(Box::new(|info| {
println!("Panic: {}", info);
}));
let mut toast = use_signal(|| ToastManager::default());
rsx! {
dioxus_toast::ToastFrame {
manager: toast
}
div {
button {
onclick: move |_| {
let _id = toast.write().popup(ToastInfo::simple("hello world"));
println!("New Toast ID: {}", _id);
},
"Normal Toast"
}
button {
onclick: move |_| {
let _id = toast.write().popup(ToastInfo::success("Hello World!", "Success"));
println!("New Toast ID: {}", _id);
},
"Success Toast"
}
button {
onclick: move |_| {
let _id = toast.write().popup(ToastInfo {
heading: Some("top-right".into()),
context: "Top Right Toast".into(),
allow_toast_close: true,
position: dioxus_toast::Position::TopRight,
icon: None,
hide_after: None
});
},
"Top Right"
}
}
}
}
Dependencies
~4–44MB
~635K SLoC