Set a value exactly: type it once focused, or step it with the arrow keys and the buttons on either side; drag across the value to scrub it.
Installation
Components are distributed as source. Copy it and what it depends on into your project, then change it as you need:
cargo run --release --bin amenui -- add number --to ../my-appFiles copied: src/widgets/number.rs, src/widgets/mod.rs
Usage
use amenui::widgets::{number};
fn view() -> El<Msg> {
number("n1", "份数", 3.0, Spec { min: 0.0, max: 9.0, step: 1.0, decimals: 0, unit: "" }, None, Msg::Num).width(320.0)
}Examples
With a unit
fn view() -> El<Msg> {
number("n2", "宽度", 12.5, Spec { min: 0.0, max: 64.0, step: 0.5, decimals: 1, unit: "px" }, None, Msg::Num).width(320.0)
}API
| Functions | number |
|---|---|
| Props | key, label, value, spec: Spec (min, max, step, decimals, unit), draft (what is being typed), msg. |
| Files | src/widgets/number.rs |
| Depends on | base |
| Response to fronts | nudge (a control: pushed as one piece by fronts, held and condensing at most to Look::legible_cap) |
| Recomposition | its value text ({key}/shown) recomposes when the value changes |
Keyboard and accessibility
| States | rest, focused, typing (ink border, accent caret), disabled; a new value recomposes its digits ({key}/shown). |
|---|---|
| Keys and messages | msg(Edit::Draft(s)) while typing, Edit::Set(v) on Enter / steps / arrows / scrub, Edit::Cancel on Esc or blur. |
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 form