<- Back to Forms Components

Checkbox is a boolean form input. Use it for explicit yes/no choices or multi-option checklists.

Contract

Property Type Notes
label str Text shown next to the checkbox.
checked bool Current boolean state. Supports literal, store binding, and data-model binding.
action str or action object Optional action emitted on change. Action objects can include confirm.
params dict Optional action context.

Value collected by actions: bool.

Action Confirmation

Use an action object with confirm to require confirmation before the checkbox change action is dispatched. If the user cancels the dialog, no backend action is sent and the checkbox keeps its previous state.

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

field = sdk.ui.Checkbox(
    "confirm_python_checkbox",
    sdk.i18n.t("components.checkbox.confirm.python_label"),
    checked=False,
)
field.set_prop(
    "action",
    {
        "name": "components.checkbox_confirm_action",
        "context": {"source": "python_checkbox"},
        "confirm": {
            "text": sdk.i18n.t("components.checkbox.confirm.prompt"),
            "confirm_text": sdk.i18n.t("components.checkbox.confirm.accept"),
            "cancel_text": sdk.i18n.t("components.checkbox.confirm.cancel"),
        },
    },
)

Example

field = sdk.ui.Checkbox(
    "components_test_forms_checkbox_store",
    "Checkbox",
    checked=bound.store("/components_test/forms/checkbox/store", scope="page", default=False),
)

Runtime

Use collect_input_ids to read true or false. Use checked.set property updates, stateUpdate, or dataModelUpdate to change the value from an action.