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

docs / components / inputs / slider docs / components / inputs /

slider

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

Pick a value roughly within a range.

For an exact value, use a number control.

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

Files copied: src/widgets/slider.rs, src/widgets/mod.rs, src/widgets/number.rs

Usage

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

fn view() -> El<Msg> {
    slider("sl1", 40.0, Spec { min: 0.0, max: 100.0, step: 1.0, decimals: 0, unit: "" }, 240.0, Msg::Value)
}

API

Functionsslider
Propskey, value, spec, width, msg.
Filessrc/widgets/slider.rs
Depends onbase, number
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

Statesrest, focused, dragging (captured until release; the thumb turns to the accent).
Keys and messagesmsg(v) while dragging and on Left / Right / Home / End.

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