The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
marimo has a rich set of UI components.
mo.ui.altair_chart(altair_chart)- create a reactive Altair chartmo.ui.button(value=None, kind='primary')- create a clickable buttonmo.ui.run_button(label=None, tooltip=None, kind='primary')- create a button that runs codemo.ui.checkbox(label='', value=False)- create a checkboxmo.ui.chat(placeholder='', value=None)- create a chat interfacemo.ui.date(value=None, label=None, full_width=False)- create a date pickermo.ui.dropdown(options, value=None, label=None, full_width=False)- create a dropdown menumo.ui.file(label='', multiple=False, full_width=False)- create a file upload elementmo.ui.number(value=None, label=None, full_width=False)- create a number inputmo.ui.radio(options, value=None, label=None, full_width=False)- create radio buttonsmo.ui.refresh(options: List[str], default_interval: str)- create a refresh controlmo.ui.slider(start, stop, value=None, label=None, full_width=False, step=None)- create a slidermo.ui.range_slider(start, stop, value=None, label=None, full_width=False, step=None)- create a range slidermo.ui.table(data, columns=None, on_select=None, sortable=True, filterable=True)- create an interactive tablemo.ui.text(value='', label=None, full_width=False)- create a text inputmo.ui.text_area(value='', label=None, full_width=False)- create a multi-line text inputmo.ui.data_explorer(df)- create an interactive dataframe explorermo.ui.dataframe(df)- display a dataframe with search, filter, and sort capabilitiesmo.ui.plotly(plotly_figure)- create a reactive Plotly chart (supports scatter, treemap, and sunburst)mo.ui.tabs(elements: dict[str, mo.ui.Element])- create a tabbed interface from a dictionarymo.ui.array(elements: list[mo.ui.Element])- create an array of UI elementsmo.ui.form(element: mo.ui.Element, label='', bordered=True)- wrap an element in a form
As always, you can learn more about the available inputs to all these components via uv --with marimo run python -c "import marimo as mo; help(mo.ui.form)"
Forms
You can compose multiple UI elements into a single form using .batch().form(). The .batch() method binds named UI elements into a markdown template, and .form() adds a submit button so values are only sent on submit.
form = (
mo.md(
"""
**Choose an option**
{choice}
**Enter some text**
{text}
**Enable feature**
{flag}
"""
)
.batch(
choice=mo.ui.dropdown(options=["A", "B", "C"]),
text=mo.ui.text(),
flag=mo.ui.checkbox(),
)
.form(
submit_button_label="Submit",
show_clear_button=True, # optional
clear_on_submit=False, # keep values after submit
)
)
form
You can also add validation to a form using the validate parameter. Return an error string to block submission, or None to allow it.
group_by_form = mo.ui.dropdown(
options=df_columns,
label="Select column to filter for duplicate analyzis",
allow_select_none=True,
value=None, # start with nothing selected
searchable=True,
).form(
submit_button_label="Apply",
validate=lambda v: (
"Please select a column and press Apply."
if v is None else None
),
)
However, the user may also want to use other components. Popular alternatives include the ScatterWidget from the drawdata library, moutils, and wigglystuff.
For custom classes and static HTML representations you can also use the _display_ method.
class Dice:
def _display_(self):
import random
return f"You rolled {random.randint(0, 7)}"