pub struct RadioGroup<T, A = ()> { /* private fields */ }Expand description
A typed single-selection set of radio options.
Selection can be controlled or two-way bound. Without a writable signal or callback the group is read-only. Arrows wrap and skip disabled options; Home/End select first/last. With no matching value, forward movement and Enter/Space choose first while backward movement chooses last.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<&str, ()> = RadioGroup::new()
.option("daily", "Daily")
.option("weekly", "Weekly")
.selected("daily");
let _ = group;Implementations§
Source§impl<T: Clone + PartialEq + 'static, A: 'static> RadioGroup<T, A>
impl<T: Clone + PartialEq + 'static, A: 'static> RadioGroup<T, A>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an enabled empty vertical group with no selection/callback.
Empty groups measure zero by zero and are not focusable.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<i32, ()> = RadioGroup::new();
let _ = group;Sourcepub fn option(self, value: T, label: impl Into<String>) -> Self
pub fn option(self, value: T, label: impl Into<String>) -> Self
Appends an enabled typed option.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<i32, ()> = RadioGroup::new().option(1, "One");
let _ = group;Sourcepub fn radio_option(self, option: RadioOption<T>) -> Self
pub fn radio_option(self, option: RadioOption<T>) -> Self
Appends a fully configured option.
§Examples
use ailloli_ui_widgets::controls::{RadioGroup, RadioOption};
let group: RadioGroup<i32, ()> = RadioGroup::new()
.radio_option(RadioOption::new(1, "One").disabled(true));
let _ = group;Sourcepub fn selected(self, selected: impl Into<Binding<T>>) -> Self
pub fn selected(self, selected: impl Into<Binding<T>>) -> Self
Sets controlled static/reactive selection and clears bound mode.
A value absent from options paints no selection. Equal duplicate values may paint multiple checked options.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<i32, ()> = RadioGroup::new().option(1, "One").selected(1);
let _ = group;Sourcepub fn bind(self, selected: impl Into<Signal<T>>) -> Self
pub fn bind(self, selected: impl Into<Signal<T>>) -> Self
Installs a writable signal for two-way group selection.
§Examples
use std::{cell::RefCell, rc::Rc};
use ailloli_ui_runtime::component::Signal;
use ailloli_ui_widgets::controls::RadioGroup;
let selected = Signal::new(Rc::new(RefCell::new(1)), Rc::new(|| {}));
let group: RadioGroup<i32, ()> = RadioGroup::new().option(1, "One").bind(selected);
let _ = group;Sourcepub fn disabled(self, disabled: impl Into<Binding<bool>>) -> Self
pub fn disabled(self, disabled: impl Into<Binding<bool>>) -> Self
Sets static or reactive global disabled state.
Disabled groups are not focusable and ignore interaction.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<i32, ()> = RadioGroup::new().disabled(true);
let _ = group;Sourcepub fn disabled_signal(self, disabled: Memo<bool>) -> Self
pub fn disabled_signal(self, disabled: Memo<bool>) -> Self
Sets global disabled state from a derived memo.
§Examples
use ailloli_ui_runtime::component::Memo;
use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<i32, ()> = RadioGroup::new().disabled_signal(Memo::new(|| false));
let _ = group;Sourcepub fn direction(self, direction: RadioDirection) -> Self
pub fn direction(self, direction: RadioDirection) -> Self
Sets vertical or horizontal option flow.
§Examples
use ailloli_ui_widgets::controls::{RadioDirection, RadioGroup};
let group: RadioGroup<i32, ()> = RadioGroup::new().direction(RadioDirection::Horizontal);
let _ = group;Sourcepub fn vertical(self) -> Self
pub fn vertical(self) -> Self
Selects vertical top-to-bottom option flow.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<i32, ()> = RadioGroup::new().vertical();
let _ = group;Sourcepub fn horizontal(self) -> Self
pub fn horizontal(self) -> Self
Selects horizontal left-to-right option flow.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<i32, ()> = RadioGroup::new().horizontal();
let _ = group;Sourcepub fn radio_style(self, style: RadioStyle) -> Self
pub fn radio_style(self, style: RadioStyle) -> Self
Replaces complete colors and option geometry.
§Examples
use ailloli_ui_widgets::controls::{RadioGroup, RadioStyle};
let group: RadioGroup<i32, ()> = RadioGroup::new().radio_style(RadioStyle::default());
let _ = group;Sourcepub fn radio_size(self, size: RadioSize) -> Self
pub fn radio_size(self, size: RadioSize) -> Self
Replaces style with a default-theme built-in size.
§Examples
use ailloli_ui_widgets::controls::{RadioGroup, RadioSize};
let group: RadioGroup<i32, ()> = RadioGroup::new().radio_size(RadioSize::Compact);
let _ = group;Sourcepub fn on_change(self, f: impl Fn(T) -> A + 'static) -> Self
pub fn on_change(self, f: impl Fn(T) -> A + 'static) -> Self
Maps each distinct enabled selection to an application action.
The callback does not make a controlled source writable; use Self::bind
for two-way state.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
#[derive(Clone)]
enum Action { Selected(i32) }
let group = RadioGroup::new().option(1, "One").on_change(Action::Selected);
let _ = group;Sourcepub fn on_change_ctx(self, f: impl Fn(&mut EventCtx<A>, T) + 'static) -> Self
pub fn on_change_ctx(self, f: impl Fn(&mut EventCtx<A>, T) + 'static) -> Self
Installs a context-aware selection handler.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let group = RadioGroup::<i32, ()>::new()
.option(1, "One")
.on_change_ctx(|_ctx, value| assert_eq!(value, 1));
let _ = group;Sourcepub fn width(self, value: impl Into<Length>) -> Self
pub fn width(self, value: impl Into<Length>) -> Self
Sets preferred width from logical pixels or an explicit Length.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().width(240.0);Sourcepub fn height(self, value: impl Into<Length>) -> Self
pub fn height(self, value: impl Into<Length>) -> Self
Sets preferred height from logical pixels or an explicit Length.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().height(120.0);Sourcepub fn min_width(self, value: impl Into<Length>) -> Self
pub fn min_width(self, value: impl Into<Length>) -> Self
Sets the minimum resolved width.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().min_width(120.0);Sourcepub fn max_width(self, value: impl Into<Length>) -> Self
pub fn max_width(self, value: impl Into<Length>) -> Self
Sets the maximum resolved width.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().max_width(400.0);Sourcepub fn min_height(self, value: impl Into<Length>) -> Self
pub fn min_height(self, value: impl Into<Length>) -> Self
Sets the minimum resolved height.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().min_height(28.0);Sourcepub fn max_height(self, value: impl Into<Length>) -> Self
pub fn max_height(self, value: impl Into<Length>) -> Self
Sets the maximum resolved height.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().max_height(300.0);Sourcepub fn fill(self) -> Self
pub fn fill(self) -> Self
Marks both axes as parent-fill.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().fill();Sourcepub fn fill_width(self) -> Self
pub fn fill_width(self) -> Self
Marks width as parent-fill while preserving height.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().fill_width();Sourcepub fn fill_height(self) -> Self
pub fn fill_height(self) -> Self
Marks height as parent-fill while preserving width.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().fill_height();Sourcepub fn margin(self, value: f32) -> Self
pub fn margin(self, value: f32) -> Self
Sets the same logical-pixel margin on every side.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().margin(8.0);Sourcepub fn padding(self, value: f32) -> Self
pub fn padding(self, value: f32) -> Self
Sets the same logical-pixel layout padding on every side.
This is separate from RadioStyle::option_padding_x.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().padding(4.0);Sourcepub fn flex_grow(self) -> Self
pub fn flex_grow(self) -> Self
Sets the dimensionless parent flex-grow weight to one.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().flex_grow();Sourcepub fn flex_grow_by(self, value: f32) -> Self
pub fn flex_grow_by(self, value: f32) -> Self
Sets the dimensionless parent flex-grow weight.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().flex_grow_by(2.0);Sourcepub fn flex_shrink(self, value: f32) -> Self
pub fn flex_shrink(self, value: f32) -> Self
Sets the dimensionless parent flex-shrink weight.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().flex_shrink(0.5);Sourcepub fn flex_basis(self, value: impl Into<Length>) -> Self
pub fn flex_basis(self, value: impl Into<Length>) -> Self
Sets the preferred parent main-axis flex basis.
§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().flex_basis(160.0);Sourcepub fn align_self(self, value: AlignItems) -> Self
pub fn align_self(self, value: AlignItems) -> Self
Overrides this item’s parent cross-axis alignment.
§Examples
use ailloli_ui_core::style::AlignItems;
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().align_self(AlignItems::End);