Sections that open and close under their headings.
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 accordion --to ../my-appFiles copied: src/widgets/accordion.rs, src/widgets/mod.rs
Usage
use amenui::widgets::{accordion};
fn view() -> El<Msg> {
accordion("a1", vec![("什么是材质", text("第二遍的画法。", 13.0, Paint::TEXT)), ("什么是预设", text("一组数据。", 13.0, Paint::TEXT))], &[true, false], Msg::Pick).width(320.0)
}API
| Functions | accordion |
|---|---|
| Props | key, items (title, body), open (which are open), msg. |
| Files | src/widgets/accordion.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 | each section open or closed; headings are buttons with aria-expanded. |
|---|---|
| Keys and messages | msg(i) toggles section i (press, Enter, Space); Up / Down move between headings by Tab. |
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).