Choose one of a few mutually exclusive options.
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 choice --to ../my-appFiles copied: src/widgets/choice.rs, src/widgets/mod.rs
Usage
use amenui::widgets::{choice, segmented};
fn view() -> El<Msg> {
choice("c1", "大小", &["小", "中", "大"], 1, Msg::Pick)
}Examples
Segmented
fn view() -> El<Msg> {
segmented("c2", &["日", "周", "月"], 0, 28.0, Msg::Pick)
}API
| Functions | choice, segmented |
|---|---|
| Props | choice(key, label, options, current, msg); segmented(key, options, current, height, msg). |
| Files | src/widgets/choice.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 | the current option is an ink plate with its label in the ground's colour; segmented is one focus stop, Left / Right move. |
|---|---|
| Keys and messages | msg(i) with the option's index. |
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).