Skip to main content

Module radio_group

Module radio_group 

Source
Expand description

RadioGroup — invisible layout container that groups RadioButtons and wires their accessibility metadata.

Radios are a fundamentally group-based control: screen readers need to announce “2 of 3” positional info, which AccessKit models via push_to_radio_group([sibling_ids]) on each radio button. Loose RadioButtons scattered in an HStack can’t self-assemble this relation because they have no knowledge of their siblings.

RadioGroup solves this by owning a shared Rc<RefCell<Vec<WidgetId>>> buffer, injecting it into each RadioButton child before adding them to the arena, and populating the buffer with each radio’s WidgetId as it’s created. RadioButton::accessibility() reads the buffer and emits the push_to_radio_group calls.

The widget is a pure layout wrapper — it delegates actual rendering to an HStack or VStack under the hood. Its own accessibility node carries Role::RadioGroup + an optional accessible name.

let selected = ctx.signal(0_usize);
RadioGroup::new()
    .label(lit!("Theme"))
    .radio(RadioButton::new(0, selected.clone()).label(lit!("Light")))
    .radio(RadioButton::new(1, selected.clone()).label(lit!("Dark")))
    .radio(RadioButton::new(2, selected.clone()).label(lit!("System")))

Structs§

RadioGroup
Invisible layout container that groups RadioButtons for accessibility. Arranges children in an HStack or VStack and carries Role::RadioGroup on its own a11y node.