跳到正文

Toast

显示定时堆叠通知,支持操作、关闭和滑动手势。

正在加载交互演示…

#导入

从 quickgui 导入 Toast。

use quickgui::*;

#用法

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

#结构

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

#API 参考

展开条目查看说明和完整签名。短横线表示声明中未记录默认值。

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
查看源码
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
查看源码
kindpub const fn kind(mut self, kind: ToastKind) -> Self—

Configures kind for this part.

pub const fn kind(mut self, kind: ToastKind) -> Self
查看源码
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
查看源码
persistentpub const fn persistent(mut self) -> Self—

Keep this toast until it is dismissed explicitly.

pub const fn persistent(mut self) -> Self
查看源码
titlepub fn title(&self) -> &Arc<str>—

Configures title for this part.

pub fn title(&self) -> &Arc<str>
查看源码
description_textpub fn description_text(&self) -> Option<&Arc<str>>—

Configures description text for this part.

pub fn description_text(&self) -> Option<&Arc<str>>
查看源码
action_labelpub fn action_label(&self) -> Option<&Arc<str>>—

Configures action label for this part.

pub fn action_label(&self) -> Option<&Arc<str>>
查看源码
toast_kindpub const fn toast_kind(&self) -> ToastKind—

Configures toast kind for this part.

pub const fn toast_kind(&self) -> ToastKind
查看源码
duration_valuepub const fn duration_value(&self) -> Option<Duration>—

Configures duration value for this part.

pub const fn duration_value(&self) -> Option<Duration>
查看源码

toast_viewport

查看源码
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())`.