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

Radiobox and Group

RadioGroup

A group of radio buttons for choosing exactly one value.

with sc.RadioGroup(
    'Project scope',
    options=('All', 'Current', 'Selected'),
    value='Current',
) as radio:
    @radio.value.on_change
    def _():
        scope.set(radio.value.get())
ArgumentTypeMeaning
labelstr | PropertyLabel
optionssequence | PropertyChoices
indexintSelected position
valueanySelected value
formatcallable or sequenceLabels
horizontalboolLay out in a row
max_heightintCap and scroll the list
enabledbool | PropertyWhether input is accepted
box_disabledcallablePredicate for rows that cannot be selected
label_visibilitystrSee Inputs

Properties: label, options, index, value, focused_index.

Signals: value.on_change (radio['on_value']), options.on_change.

Radio = RadioGroup is an alias, matching the name used in some Streamlit examples.

Choosing between RadioGroup and Selectbox

Use RadioGroup when every option should be visible at once and the list is short. Use Selectbox when the list is long or the space is tight.

Disabled rows

box_disabled marks rows that are visible but cannot be selected:

sc.RadioGroup(
    'Target',
    options=('dev', 'prod'),
    box_disabled=lambda x: x == 'prod',
)

The tree panels use this for the .. navigation row, which is a target for a click but not a value.