Skip to main content

mo.ui.radio

Create a radio button group for selecting one option.

Signature

mo.ui.radio(
    options: Sequence[str] | dict[str, Any],
    value: str | None = None,
    inline: bool = False,
    *,
    label: str = "",
    on_change: Callable[[Any], None] | None = None,
    disabled: bool = False
)

Parameters

options
Sequence[str] | dict[str, Any]
required
List of options or dictionary mapping labels to values
value
str
Initially selected value
inline
bool
default:"False"
Display options horizontally instead of vertically
label
str
default:"''"
Markdown label for the radio group
disabled
bool
default:"False"
Whether the radio buttons are disabled

Examples

import marimo as mo

# Basic radio buttons
color = mo.ui.radio(
    options=["Red", "Green", "Blue"],
    value="Red",
    label="**Choose a color:**"
)
color
# Inline radio buttons
size = mo.ui.radio(
    options=["Small", "Medium", "Large"],
    inline=True
)
# Radio with value mapping
priority = mo.ui.radio(
    options={
        "Low priority": 1,
        "Medium priority": 2,
        "High priority": 3
    },
    value=2
)

mo.md(f"Selected priority level: {priority.value}")

Build docs developers (and LLMs) love