Expert guidance for creating and working with marimo notebooks - reactive Python notebooks that can be executed as scripts and deployed as apps...
Create reactive Python notebooks with marimo's interactive programming environment.
references/core-concepts.md - contains marimo's cell structure, reactivity model, UI elements, and essential examplesreferences/recipes.md for code snippetsreferences/api/ for specific function detailsreferences/faq.md and references/troubleshooting.mdEvery marimo cell follows this structure:
@app.cell
def _():
# Your code here
return
When editing cells, only modify the code inside the function - marimo handles parameters and returns automatically.
.value trigger automatic updates_ (e.g., _temp) are local to the cellAlways import marimo in the first cell:
@app.cell
def _():
import marimo as mo
# other imports
return
# Create UI element in one cell
@app.cell
def _():
slider = mo.ui.slider(0, 100, value=50, label="Value")
slider
return
# Use its value in another cell
@app.cell
def _():
result = slider.value * 2
mo.md(f"Double the value: {result}")
return
# Load and display data
@app.cell
def _():
import polars as pl
df = pl.read_csv("data.csv")
df # Automatically displays as table
return
# Interactive data exploration
@app.cell
def _():
mo.ui.data_explorer(df)
return
@app.cell
def _():
# marimo has built-in DuckDB support
result = mo.sql(f"""
SELECT * FROM df WHERE column > 100
""")
return
@app.cell
def _():
# Horizontal stack
mo.hstack([element1, element2, element3])
# Vertical stack
mo.vstack([top, middle, bottom])
# Tabs
mo.tabs({"Tab 1": content1, "Tab 2": content2})
return
plt.gca() as last expression (not plt.show())Use references/NAVIGATION.md to understand the complete documentation structure. Key references:
.value in the same cell where UI element is definedglobal - violates marimo's execution modelRun marimo check --fix to automatically catch and fix common formatting issues and detect pitfalls.
mo.ui.slider(start, stop, value=None, label=None)
mo.ui.dropdown(options, value=None, label=None)
mo.ui.text(value='', label=None)
mo.ui.button(value=None, kind='primary')
mo.ui.checkbox(label='', value=False)
mo.ui.table(data, sortable=True, filterable=True)
mo.ui.data_explorer(df) # Interactive dataframe explorer
mo.ui.dataframe(df) # Editable dataframe
mo.ui.form(element, label='') # Wrap elements in a form
mo.ui.array(elements) # Array of UI elements
See references/api/inputs/index.md for the complete list.
mo.md(text) # Display markdown
mo.hstack(elements) # Horizontal layout
mo.vstack(elements) # Vertical layout
mo.tabs(dict) # Tabbed interface
mo.stop(predicate, output=None) # Conditional execution
mo.output.append(value) # Append to output
mo.output.replace(value) # Replace output
See references/api/layouts/index.md for all layout options.