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

docs / components / data / table docs / components / data /

table

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

Rows of records with named columns.

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

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

Usage

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

fn view() -> El<Msg> {
    table("tb1", &[("名称", 120.0), ("大小", 60.0)], &[vec!["a.png".into(), "12 KB".into()], vec!["b.png".into(), "3 KB".into()]], Some(0), Msg::Pick)
}

API

Functionstable
Propskey, columns (name, width), rows (cells as text), selected, msg.
Filessrc/widgets/table.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

Statesa selected row (highlighted); one focus stop, Up / Down move the selection.
Keys and messagesmsg(i) on a row press or a key.

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).