Skip to main content

mo.App

The App class is the core container for marimo notebooks. It represents a collection of cells that form a reactive computational graph.

Overview

A marimo app is created using the @app.cell decorator to define cells. The app manages the reactive execution of cells based on their dependencies.

Creating an App

import marimo

__generated_with = "0.20.3"
app = marimo.App(width="medium")


@app.cell
def __():
    import marimo as mo
    return mo,


@app.cell
def __(mo):
    name = mo.ui.text(placeholder="Enter your name")
    name
    return name,


@app.cell
def __(mo, name):
    mo.md(f"Hello, {name.value}!")
    return

App Configuration

width
'normal' | 'medium' | 'full'
default:"'normal'"
Controls the width of the notebook layout
app_title
str
Title displayed in the browser tab
css_file
str
Path to custom CSS file for styling

Decorators

@app.cell

Defines a cell in the marimo app. Cells are executed reactively based on their dependencies.
@app.cell
def cell_name():
    # Cell code here
    x = 1
    y = 2
    return x, y
hide_code
bool
default:"False"
Whether to hide the cell code in app mode
disabled
bool
default:"False"
Whether the cell is disabled

Running Apps

Apps can be run in three modes:
  1. Edit mode: Interactive development environment
marimo edit notebook.py
  1. Run mode: View-only app with optional code hiding
marimo run notebook.py
  1. Script mode: Execute as a Python script
python notebook.py

Programmatic Execution

from marimo import App

app = App()

@app.cell
def __():
    import marimo as mo
    return mo,

# Run the app
if __name__ == "__main__":
    app.run()

App Methods

app.run()

Execute the app as a script. This runs all cells in dependency order.

app.export_html()

Export the app to a standalone HTML file.
app.export_html("output.html")

ASGI Integration

Create an ASGI app for deployment:
from marimo import create_asgi_app

# Create ASGI app from notebook file
asgi_app = create_asgi_app()
    .with_app(path="/", root="notebook.py")
    .build()
Apps are stored as pure Python files, making them git-friendly and executable as scripts.

Cell

Learn about marimo cells

Creating Notebooks

Guide to creating marimo notebooks

Build docs developers (and LLMs) love