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

docs / components / inputs / radio docs / components / inputs /

radio

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

Choose one of a few visible options.

One focus stop; the arrows move and select.

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

Files copied: src/widgets/radio.rs, src/widgets/mod.rs

Usage

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

fn view() -> El<Msg> {
    radio_group("r1", &["小", "中", "大"], 1, Msg::Pick)
}

API

Functionsradio_group
Propskey, options, current, msg.
Filessrc/widgets/radio.rs
Depends onbase
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

Statesone option selected; one focus stop for the group.
Keys and messagesmsg(i); options are keyed key:i. Arrow keys move the selection (WAI-ARIA radio group: Up/Left the previous, Down/Right the next, wrapping; Home / End the ends).

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