Radio represents a single choice; wrap them in a RadioGroup to link them together and track the selected value.
Basic Usage
ARadioGroup is a container that holds Radio children. Each radio needs an option (what gets stored when selected) and a label (what the user sees). The group tracks which radio is selected and stores its option string in state:
Pre-selected Option
Setvalue=True on a radio to have it selected when the component first renders:
Disabled Options
Individual radios can be disabled while the rest of the group remains interactive. This is useful for options that exist but aren’t currently available:Reading the Value
Use.rx on the RadioGroup to get a reactive reference to the selected radio’s option string. When the user clicks a different option, anything bound to .rx updates automatically:
Click a radio and the text updates instantly. The .rx reference holds the option string — "heart-of-gold", "bistromath", etc. — not the label.
Actions
Theon_change parameter on RadioGroup fires actions when the selection changes. Inside the action, $event holds the newly selected option string:
For simple “show the current selection” cases, .rx is the better approach. Use on_change when you need to transform the value or trigger side effects.
API Reference
RadioGroup Parameters
State key for the selected value. Auto-generated if not provided.
Action(s) to execute when the selection changes.
$event is the value string of the selected radio.Additional Tailwind CSS classes.
Radio Parameters
The option identifier stored in the group’s state when this radio is selected. Defaults to the label.
Label text displayed next to the radio button.
Whether this radio is initially selected.
Whether this radio is non-interactive.
Whether a selection is required for form submission.
Additional Tailwind CSS classes.
Protocol Reference
RadioGroup
Radio