Skip to main content

Module snackbar

Module snackbar 

Source
Expand description

Snackbar — a transient, button-triggered floating notification surface.

A Snackbar pairs a trigger (a Button by default, or any custom widget via .trigger(...)) with a dormant content surface. Activating the trigger presents the surface as an OverlayPlacement::BottomCenter overlay and dismisses it automatically after a configurable timeout (default: 4 s). The surface stays until dismissed when .persistent() is set. Only one snackbar can be shown at a time — presenting a second one dismisses the first.

For richer, stackable, severity-aware notifications see the Toast system, which also maintains a persistent NotificationArchiveModel.

§Accessibility

The content surface exposes Role::Alert with Live::Polite so screen readers announce the notification without interrupting the user. Supply .announcement(...) to give the alert a descriptive name instead of the generic “notification” fallback.

use teksilo_widgets::{Snackbar};
use teksilo_i18n::lit;
use teksilo_widgets::primitives::TextWidget;
use teksilo_tokens::TextRole;

// In build():
ctx.add(
    Snackbar::new(lit!("Undo"))
        .content(TextWidget::new(lit!("File deleted.")).color(TextRole::TooltipText))
        .announcement(lit!("File deleted."))
        .auto_dismiss_after(std::time::Duration::from_secs(5)),
);

Structs§

Snackbar
A button-triggered transient notification surface.