<- Back to Forms Components

RadioGroup is a single-choice input rendered as a radio button group.

Contract

Property Type Notes
label str Group label.
options list[dict] Option entries with label and value.
value str Current selected option value.
action action object Optional action emitted on change. Action objects can include confirm.
options_action str | None Optional action source for options.
options_store str | None Optional store source for options.

Value collected by actions: str.

Action Confirmation

Use an action object with confirm to require confirmation before the radio selection action is dispatched. If the user cancels the dialog, no backend action is sent and the group keeps its previous value.

The component test page exposes a radio group action counter and the last received payload so dispatch can be checked directly after confirming.

field = sdk.ui.RadioGroup(
    "confirm_python_radiogroup",
    sdk.i18n.t("components.radiogroup.confirm.python_label"),
    options=[
        {"label": sdk.i18n.t("components.choice.confirm.option_alpha"), "value": "alpha"},
        {"label": sdk.i18n.t("components.choice.confirm.option_beta"), "value": "beta"},
        {"label": sdk.i18n.t("components.choice.confirm.option_gamma"), "value": "gamma"},
    ],
    value="alpha",
)
field.set_prop(
    "action",
    {
        "name": "components.radiogroup_confirm_action",
        "context": {"source": "python_radiogroup"},
        "confirm": {
            "text": sdk.i18n.t("components.radiogroup.confirm.prompt"),
            "confirm_text": sdk.i18n.t("components.radiogroup.confirm.accept"),
            "cancel_text": sdk.i18n.t("components.radiogroup.confirm.cancel"),
        },
    },
)

Example

field = sdk.ui.RadioGroup(
    "components_test_forms_radiogroup_store",
    "RadioGroup",
    options=[
        {"label": "Small", "value": "small"},
        {"label": "Medium", "value": "medium"},
        {"label": "Large", "value": "large"},
    ],
    value=bound.store("/components_test/forms/radiogroup/store", scope="page", default="small"),
)

Runtime

Use collect_input_ids to read the selected option value. Use value.set, stateUpdate, or dataModelUpdate to change the selection from an action.