A button that shows the current option; pressing it lists every option in a layer below it.
Press one to choose it; press outside the list or Esc to close.
Installation
Components are distributed as source. Copy it and what it depends on into your project, then change it as you need:
cargo run --release --bin amenui -- add menu --to ../my-appFiles copied: src/widgets/menu.rs, src/widgets/mod.rs
Usage
use amenui::widgets::{menu};
fn view() -> El<Msg> {
menu("m1", "主题", &["暗", "明", "纸"], Some(0), false, false, Msg::Nothing, Msg::Nothing, Msg::Pick)
}API
| Functions | menu |
|---|---|
| Props | key, label, options, current, open, commit (the choice is a commit: theme, material), toggle, close, pick. |
| Files | src/widgets/menu.rs |
| Depends on | base |
| Response to fronts | nudge (a control: pushed as one piece by fronts, held and condensing at most to Look::legible_cap) |
| Recomposition | keyed labels recompose when their text changes |
Keyboard and accessibility
| States | closed (shows the current option) or open (a layer under the button). |
|---|---|
| Keys and messages | toggle on the button, pick(i) on an option, close outside or on Esc. |
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).