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

docs / components / data / list docs / components / data /

list

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

Show a set of items, one of which can be selected; it scrolls when there are many.

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

Files copied: src/widgets/list.rs, src/widgets/mod.rs

Usage

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

fn view() -> El<Msg> {
    list("l1", &[("苹果", "3"), ("梨", "5"), ("桃", "1")], Some(1), 36.0, 140.0, Msg::Pick)
}

API

Functionslist
Propskey, rows (label, note) or count + row_of(i), selected, row_h, height, msg.
Filessrc/widgets/list.rs
Depends onbase
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

Statesselected row highlighted; one focus stop; Up / Down / Home / End / Page keys move the selection.
Keys and messagesmsg(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