Perform an action.
It fires on press, and Enter or Space fire it too.
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 button --to ../my-appFiles copied: src/widgets/button.rs, src/widgets/mod.rs
Usage
use amenui::widgets::{button, button_as};
fn view() -> El<Msg> {
button_as("b1", "保存", Variant::Default, Msg::Nothing)
}Examples
Quiet
fn view() -> El<Msg> {
button_as("b2", "取消", Variant::Quiet, Msg::Nothing)
}Accent
fn view() -> El<Msg> {
button_as("b3", "发布", Variant::Accent, Msg::Nothing)
}Disabled
fn view() -> El<Msg> {
button_as("b4", "发布", Variant::Accent, Msg::Nothing).disabled(true)
}Primary
fn view() -> El<Msg> {
button_as("b5", "Save", Variant::Primary, Msg::Nothing)
}API
| Functions | button, button_as |
|---|---|
| Props | key, label, v: Variant (Default outlined, Quiet, Primary an ink plate, Accent filled), msg. |
| Files | src/widgets/button.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 | keyed labels recompose when their text changes |
Keyboard and accessibility
| States | rest, hovered, focused, pressed (held at the legibility cap, condenses back from it), disabled (.disabled(true)). |
|---|---|
| Keys and messages | sends msg on press, Enter or Space; its front reaches only itself unless .ripplr(..) says otherwise. |
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