Show a set of items, one of which can be selected; it scrolls when there are many.
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 list --to ../my-appFiles copied: src/widgets/list.rs, src/widgets/mod.rs
Usage
use amenui::widgets::{list};
fn view() -> El<Msg> {
list("l1", &[("苹果", "3"), ("梨", "5"), ("桃", "1")], Some(1), 36.0, 140.0, Msg::Pick)
}API
| Functions | list |
|---|---|
| Props | key, rows (label, note) or count + row_of(i), selected, row_h, height, msg. |
| Files | src/widgets/list.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 | selected row highlighted; one focus stop; Up / Down / Home / End / Page keys move the selection. |
|---|---|
| Keys and messages | msg(i) with the row index; rows are keyed key:i. |
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 list with selection