Radios are used when only one choice may be selected in a series of options.

No Selection
from typing import List

options: List[str] = ["Option 1", "Option 2", "Option 3"]


class RadioState(rx.State):
    text: str = "No Selection"


def basic_radio_example():
    return rc.vstack(
        rc.badge(RadioState.text, color_scheme="green"),
        rc.radio_group(
            options,
            on_change=RadioState.set_text,
        ),
    )

The default_value and default_checked arguments can be used to set the default value of the radio group.

rc.vstack(
    rc.radio_group(
        options,
        default_value="Option 2",
        default_checked=True,
    ),
)

A hstack with the spacing argument can be used to set the spacing between the radio buttons.

rc.radio_group(
    rc.radio_group(
        rc.hstack(
            rx.foreach(
                options,
                lambda option: rc.radio(option),
            ),
            spacing="2em",
        ),
    ),
)

A vstack can be used to stack the radio buttons vertically.

rc.radio_group(
    rc.radio_group(
        rc.vstack(
            rx.foreach(
                options,
                lambda option: rc.radio(option),
            ),
        ),
    ),
)

rc.RadioGroup

A grouping of individual radio options.

PropType | ValuesDefault
value
Any
default_value
Any
name
str

Event Triggers

See the full list of default event triggers
TriggerDescription
on_change Fired when the radio group value changes.

rc.Radio

Radios are used when only one choice may be selected in a series of options.

PropType | ValuesDefault
value
Any
default_value
Any
color_scheme
str
default_checked
bool
is_checked
bool
is_disabled
bool
is_invalid
bool
is_read_only
bool
is_required
bool
as_
str
no_of_lines
int