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

docs / components / display / skeleton docs / components / display /

skeleton

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

Holds the place of content that is still loading.

Better: El::skeleton() on the real rows — the same tree and layout, text drawn as bars of the measured line widths, pictures as blocks; the Loading rules (a skeleton only after skeleton_after_ms 300, rows swapped in swap_stagger_ms 40 apart) decide what shows, and nothing moves when the content comes.

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

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

Usage

rust
use amenui::widgets::{skeleton, Loading};

fn view() -> El<Msg> {
    row().gap(12.0).child(skeleton("sk1", 40.0, 40.0, true)).child(col().gap(8.0).child(skeleton("sk2", 180.0, 12.0, false)).child(skeleton("sk3", 120.0, 12.0, false)))
}

API

Functionsskeleton, Loading
Propskey, width, height, round (a disc rather than a bar); for a list, Loading (skeleton_after_ms, swap_stagger_ms) and El::skeleton() on the real rows.
Filessrc/widgets/skeleton.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

Statesnothing yet (the first skeleton_after_ms), skeleton, content (row by row); it stays still: no shimmer, loading is not an animation here.
Keys and messagesnone.

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 that loads