Skip to main content

mo.ui.checkbox

Create a checkbox for boolean input.

Signature

mo.ui.checkbox(
    value: bool = False,
    *,
    label: str = "",
    disabled: bool = False,
    on_change: Callable[[bool], None] | None = None
)

Parameters

value
bool
default:"False"
Initial checked state
label
str
default:"''"
Markdown label for the checkbox
disabled
bool
default:"False"
Whether the checkbox is disabled

Examples

import marimo as mo

# Basic checkbox
agree = mo.ui.checkbox(label="I agree to the terms")
agree
# Use the value
if agree.value:
    mo.md("Thank you for agreeing!")
# Multiple checkboxes
options = mo.md(
    f"""
    Select your preferences:
    
    {mo.ui.checkbox(label="Email notifications")}
    {mo.ui.checkbox(label="SMS alerts")}
    {mo.ui.checkbox(label="Newsletter")}
    """
)

Build docs developers (and LLMs) love