Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

RadioButton

An input where one option in a group can be selected.

When To Use It

Use RadioButton when users must choose exactly one option from a small set, such as quality presets, themes, or sort modes.

Constructing a RadioButton

A RadioButton binds to a bool checked state and triggers on_select when pressed:

let is_selected = Signal::new(false);

RadioButton::new(cx, is_selected)
	.on_select(|cx| cx.emit(AppEvent::SelectOption));

Typical grouped layout:

VStack::new(cx, |cx| {
	HStack::new(cx, |cx| {
		RadioButton::new(cx, mode.map(|m| *m == Mode::Low))
			.on_select(|cx| cx.emit(AppEvent::SetMode(Mode::Low)));
		Label::new(cx, "Low");
	});

	HStack::new(cx, |cx| {
		RadioButton::new(cx, mode.map(|m| *m == Mode::High))
			.on_select(|cx| cx.emit(AppEvent::SetMode(Mode::High)));
		Label::new(cx, "High");
	});
});

RadioButton Modifiers

ModifierTypeDescriptionDefault
on_selectFn(&mut EventContext)Called when the radio button is selected.-

Components and Styling

RadioButton uses a root radiobutton element with an inner dot.

SelectorDescription
radiobuttonRoot radio button element.
radiobutton .innerInner indicator element.
radiobutton:checkedChecked state.
radiobutton:disabledDisabled state.

Accessibility

RadioButton sets role RadioButton, is checkable, and is keyboard navigable.

Keyboard interaction:

KeyAction
Space / EnterSelects the radio button when focused.