amenui
en·中 github ↗ v0.0.1
01docs 02components 03lab 04works
en·中github ↗
×

docs / components / feedback / toast docs / components / feedback /

toast

04.21
On this page ▾
  1. Installation
  2. Usage
  3. API
  4. Keyboard and accessibility

A brief notice in a corner that goes away by itself.

drawn by amenuiopen ↗

Installation

Components are distributed as source. Copy it and what it depends on into your project, then change it as you need:

sh
cargo run --release --bin amenui -- add toast --to ../my-app

Files copied: src/widgets/toast.rs, src/widgets/mod.rs, src/widgets/button.rs

Usage

rust
use amenui::widgets::{toast};

fn view() -> El<Msg> {
    col().width(380.0).height(110.0).child(toast("to1", "已保存", "三项改动已写入", true, Msg::Nothing))
}

API

Functionstoast
Propskey, title, body, shown, dismiss (its close button).
Filessrc/widgets/toast.rs
Depends onbase, button
Response to frontsnudge (a control: pushed as one piece by fronts, held and condensing at most to Look::legible_cap)
Recompositionkeyed labels recompose when their text changes

Keyboard and accessibility

Stateshidden, shown (at the window's bottom right, polite live region).
Keys and messagesdismiss on its close button; the application hides it after a few seconds (Ui::on_wake).

On the web every control is mirrored into the page as an element with its role and name, so screen readers and the browser's own focus see it (DESIGN.md §1.14).