Crate egui_toast

source ·
Expand description

This crate provides a convenient interface for showing toast notifications with the egui library.

For a complete example, see


To get started, create a Toasts instance in your rendering code and specify the anchor position and direction for the notifications. Toast notifications will show up starting from the specified anchor position and stack up in the specified direction.

use egui::Align2;
let mut toasts = Toasts::new()
    .anchor(Align2::LEFT_TOP, (10.0, 10.0))

toasts.add(Toast {
    text: "Hello, World".into(),
    kind: ToastKind::Info,
    options: ToastOptions::default()

// Show all toasts;

Look of the notifications can be fully customized by specifying a custom rendering function for a specific toast kind with Toasts::custom_contents. ToastKind::Custom can be used if the default kinds are not sufficient.

const MY_CUSTOM_TOAST: u32 = 0;

fn custom_toast_contents(ui: &mut egui::Ui, toast: &mut Toast) -> egui::Response {
    egui::Frame::window(, |ui| {

let mut toasts = Toasts::new()
    .custom_contents(MY_CUSTOM_TOAST, &custom_toast_contents)
    .custom_contents(ToastKind::Info, |ui, toast| {

// Add a custom toast that never expires
toasts.add(Toast {
    text: "Hello, World".into(),
    kind: ToastKind::Custom(MY_CUSTOM_TOAST),
    options: ToastOptions::default(),





Type Definitions