21 releases (breaking)

new 0.17.0 Apr 19, 2025
0.16.0 Jan 6, 2025
0.15.0 Oct 5, 2024
0.14.0 Jul 14, 2024
0.2.0 May 18, 2022

#275 in GUI

Download history 460/week @ 2024-12-27 658/week @ 2025-01-03 576/week @ 2025-01-10 452/week @ 2025-01-17 379/week @ 2025-01-24 344/week @ 2025-01-31 333/week @ 2025-02-07 397/week @ 2025-02-14 417/week @ 2025-02-21 418/week @ 2025-02-28 408/week @ 2025-03-07 482/week @ 2025-03-14 443/week @ 2025-03-21 320/week @ 2025-03-28 323/week @ 2025-04-04 321/week @ 2025-04-11

1,501 downloads per month
Used in 3 crates (2 directly)

MIT license

2.5MB
313 lines

egui-toast

Latest version Documentation MIT

Toast notifications for the egui library.

Try it out in a web demo

Toast types

Quick start

cargo run -p egui-toast-demo
# or in wasm
cd demo && trunk serve
let mut toasts = Toasts::new()
    .anchor(Align2::RIGHT_BOTTOM, (-10.0, -10.0)) // 10 units from the bottom right corner
    .direction(egui::Direction::BottomUp);

if ui.button("Add toast").clicked() {
    toasts.add(Toast {
        text: "Hello, World!".into(),
        kind: ToastKind::Error,
        options: ToastOptions::default()
            .duration_in_seconds(5.0)
            .show_progress(true),
        ..Default::default()
    });
}

// Show and update all toasts
toasts.show(ctx);

Customization

Look of the notifications can be fully customized.

const MY_CUSTOM_TOAST: u32 = 0;

fn my_custom_toast_contents(ui: &mut Ui, toast: &mut Toast) -> Response {
    egui::Frame::default()
        .fill(Color32::from_rgb(33, 150, 243))
        .inner_margin(Margin::same(12.0))
        .rounding(4.0)
        .show(ui, |ui| {
            ui.label(toast.text.clone().color(Color32::WHITE));

            if ui.button("Close me").clicked() {
                toast.close();
            }
        }).response
}

let mut toasts = Toasts::new()
    .custom_contents(MY_CUSTOM_TOAST, my_custom_toast_contents);

if ui.button("Add toast").clicked() {
    toasts.add(Toast {
        text: "Hello, World!".into(),
        kind: ToastKind::Custom(MY_CUSTOM_TOAST),
        options: ToastOptions::default(),
        ..Default::default()
    });
}

toasts.show(ctx);

Dependencies

~4.5–9.5MB
~88K SLoC