Skip to content

Toast

Presents timed, stacked notifications with action, close, and swipe behavior.

Loading interactive demo…

#Import

Import Toast from quickgui.

use quickgui::*;

#Usage

toast_viewport("toasts").child(text("Saved"))

#Anatomy

  • Toast::provider_part
  • Toast::portal
  • Toast::viewport
  • Toast::positioner
  • Toast::root
  • Toast::content
  • Toast::title
  • Toast::description
  • Toast::action
  • Toast::close

#API reference

Expand an entry for its description and complete signature. A dash means no declaration default is documented.

pub fn new(title: impl Into<Arc<str>>) -> Self

Create a toast with an auto-dismiss duration of five seconds.

descriptionpub fn description(mut self, description: impl Into<Arc<str>>) -> Self—

Configures description for this part.

pub fn description(mut self, description: impl Into<Arc<str>>) -> Self
View source
actionpub fn action(mut self, action: impl Into<Arc<str>>) -> Self—

Label one caller-owned action control, such as *Undo*.

pub fn action(mut self, action: impl Into<Arc<str>>) -> Self
View source
kindpub const fn kind(mut self, kind: ToastKind) -> Self—

Configures kind for this part.

pub const fn kind(mut self, kind: ToastKind) -> Self
View source
durationpub fn duration(mut self, duration: Duration) -> Self—

Replace the auto-dismiss duration, clamped to [`MAX_TOAST_DURATION`].

pub fn duration(mut self, duration: Duration) -> Self
View source
persistentpub const fn persistent(mut self) -> Self—

Keep this toast until it is dismissed explicitly.

pub const fn persistent(mut self) -> Self
View source
titlepub fn title(&self) -> &Arc<str>—

Configures title for this part.

pub fn title(&self) -> &Arc<str>
View source
description_textpub fn description_text(&self) -> Option<&Arc<str>>—

Configures description text for this part.

pub fn description_text(&self) -> Option<&Arc<str>>
View source
action_labelpub fn action_label(&self) -> Option<&Arc<str>>—

Configures action label for this part.

pub fn action_label(&self) -> Option<&Arc<str>>
View source
toast_kindpub const fn toast_kind(&self) -> ToastKind—

Configures toast kind for this part.

pub const fn toast_kind(&self) -> ToastKind
View source
duration_valuepub const fn duration_value(&self) -> Option<Duration>—

Configures duration value for this part.

pub const fn duration_value(&self) -> Option<Duration>
View source

toast_viewport

View source
pub fn toast_viewport(id: impl Into<ElementId>) -> Element

Create an unstyled toast-viewport root. This shorthand is equivalent to `ToastViewport::new(id).viewport_with(div())`.