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

docs / components / display / card stack docs / components / display /

card stack

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

A stack of cards: hover or press one and the cards beneath fan out about their bottom-left corners, card n turning angle0 × falloff^n (42° × 0.7^n) and starting delay_ms × n (28 ms) later, each on its own spring.

The cards are a 3D element, so the look follows the material: flat, thick with visible edges, or drawn in marks (dots, ASCII). Fanning out and settling, each card leaves a short trail in the field map (El::stirr).

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

Files copied: src/widgets/card_stack.rs, src/gesture.rs, src/mesh.rs, src/widgets/mod.rs

Usage

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

fn view() -> El<Msg> {
    card_stack("cs1", &Stack::default(), 260.0, 170.0, Msg::Stack)
}

API

Functionscard_stack
Propskey, stack (Stack: count, angle0, falloff, delay_ms, spring, look, card), msg.
Filessrc/widgets/card_stack.rs, src/gesture.rs, src/mesh.rs
Depends onbase
Response to frontsloosen (a 3D element is decoration, like a picture, even when it can be turned)
Recompositionnone (no text)

Keyboard and accessibility

Statesclosed, fanning (cards springing toward their angles, each after its delay), fanned under card k, held (pressed: stays fanned when the pointer leaves); arrow keys move the fan when focused, Enter or Space holds it.
Keys and messagesmsg(StackMsg) for hover and presses on a card and for keys; the application calls Stack::update and Stack::step on every tick while Stack::moving().

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 stack of cards that fans