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

docs / components / feedback / dialog docs / components / feedback /

dialog

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

Show content that needs attention above the page.

Until it closes, the rest of the page does not respond; Esc or the close button closes it.

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 dialog --to ../my-app

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

Usage

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

fn view() -> El<Msg> {
    col().gap(8.0).child(button("rename", "重命名…", Msg::Nothing)).child(dialog("d1", false, "重命名", 320.0, 0.35, Msg::Nothing, text("新的名字", 14.0, Paint::TEXT)))
}

API

Functionsdialog
Propskey, open, title, width, beneath (looseness of the page under it, about 0.35), close, body.
Filessrc/widgets/dialog.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

Statesopen or nothing; focus inside while open.
Keys and messagesclose on Esc or 关闭; whatever its body sends.

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).

Recipes: A dialog