Skip to main content

Module radio_button

Module radio_button 

Source
Expand description

RadioButton — mutually exclusive selection control.

Multiple RadioButtons share a Signal<usize>; selecting one writes its value to the signal, which automatically deselects every sibling that observes the same signal. The widget is non-generic: values are usize indices into the caller’s choice list. Wrap related buttons in a RadioGroup to provide the AT “2 of 3” positional announcement required by ARIA.

§Accessibility

Reports Role::RadioButton with set_toggled mirroring the selected state. Responds to Action::Click from assistive technology. The focus ring is keyboard-only (:focus-visible gated by the input-modality signal). When wrapped in RadioGroup, each button emits push_to_radio_group([sibling_ids]) so screen readers can announce positional membership.

let selected = Signal::new(0_usize);
let _r0 = RadioButton::new(0, selected.clone()).label(lit!("Light"));
let _r1 = RadioButton::new(1, selected.clone()).label(lit!("Dark"));
let _r2 = RadioButton::new(2, selected.clone()).label(lit!("System"));

Structs§

RadioButton
A single radio button option that writes value into a shared Signal<usize> on selection.