Choose whether one option applies.
Press, Space or Enter toggles.
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 checkbox --to ../my-appFiles copied: src/widgets/checkbox.rs, src/widgets/mod.rs
Usage
use amenui::widgets::{checkbox};
fn view() -> El<Msg> {
checkbox("cb1", "同意条款", false, Msg::Nothing)
}Examples
Checked
fn view() -> El<Msg> {
checkbox("cb2", "同意条款", true, Msg::Nothing)
}Disabled
fn view() -> El<Msg> {
checkbox("cb3", "同意条款", true, Msg::Nothing).disabled(true)
}API
| Functions | checkbox |
|---|---|
| Props | key, label, checked, msg. |
| Files | src/widgets/checkbox.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 | unchecked, checked, focused, disabled. |
|---|---|
| Keys and messages | msg on press, Space or Enter (WAI-ARIA checkbox: Space toggles). |
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).