yew-toasts

Crates.ioyew-toasts
lib.rsyew-toasts
version0.1.1
created_at2025-09-13 18:22:53.22634+00
updated_at2025-09-13 21:38:43.876651+00
descriptionSimple and easy toast notifications for Yew
homepagehttps://github.com/illuminodes/minions
repositoryhttps://github.com/illuminodes/minions
max_upload_size
id1837992
size44,116
(42Pupusas)

documentation

README

Yew Toasts

A simple and easy toast notifications for Yew.

Example

use yew::prelude::*;
use yew_toasts::{ToastData, Gravity, Position, show_toast_cb};

#[function_component(ToastButton)]
fn toast_button() -> Html {
    let inner_cb = Callback::from(move |()| {
        web_sys::console::log_1(&"clicked in".into());
    });
    let cb = yew_toasts::show_toast_cb().reform(move |_| yew_toasts::ToastData {
        element: html!(<ToastBanner/>),
        position: yew_toasts::Position::Left,
        gravity: yew_toasts::Gravity::Bottom,
        onclick: inner_cb.clone(),
        ..Default::default()
    });
    use_effect(move || {
        gloo_timers::callback::Interval::new(5000, move || {
            yew_toasts::show_toast(&yew_toasts::ToastData {
                element: html!(<ToastBanner/>),
                position: yew_toasts::Position::Center,
                gravity: yew_toasts::Gravity::Top,
                ..Default::default()
            })
            .expect("")
        })
        .forget();
    });
    html! {
        <>
        <button onclick={cb} class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">{"Test Toast"}</button>
        </>

    }
}

#[function_component(ToastBanner)]
fn toast_banner() -> Html {
    html! {
        <div class="bg-blue-500 text-white font-bold py-2 px-4 rounded">
            {"This is a test toast"}
        </div>
    }
}

#[function_component(Splash)]
fn relay_pool_test() -> Html {
    html! {
        <div class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center">
       </div>
    }
}
Commit count: 60

cargo fmt