Skip to main content

Interactive Elements

marimo provides a comprehensive library of interactive UI elements through mo.ui. These elements automatically trigger reactive execution when their values change, making it easy to build interactive data applications.
All UI elements in marimo are reactive. When you interact with a UI element, any cells that reference it automatically re-run with the new value.

Available UI Elements

marimo offers a wide variety of UI elements for different use cases:

Input Elements

Text, number, textarea, code editor

Selection Elements

Slider, dropdown, radio, multiselect, checkbox

Data Elements

Table, dataframe, data editor, data explorer

Advanced Elements

File upload, date picker, chat, microphone

Basic Input Elements

Slider

Create numeric sliders for selecting values from a range:
You can also create sliders with custom discrete steps:

Number Input

A number picker over an interval:

Text Input

Collect text input from users:

Text Area

For multi-line text input:

Selection Elements

Create dropdown menus for selecting from a list of options:

Radio Buttons

Radio buttons for mutually exclusive choices:

Multiselect

Allow users to select multiple options:

Checkbox

Simple boolean input:

Data Elements

Table

Display interactive tables with built-in filtering, sorting, and pagination:
The table element supports selection modes: "single", "multi", or None for no selection.

DataFrame

Interactive dataframe viewer with transformations:

Data Editor

Edit data directly in the UI:

Data Explorer

Powerful data exploration interface:

Advanced Elements

Button

Create clickable buttons:

Run Button

A special button that prevents automatic execution:
Use run_button for expensive operations. Cells referencing it only run when the button is clicked, not automatically.

File Upload

Upload files from the user’s computer:

Date Picker

Select dates and times:

Chat

Build chat interfaces:

Microphone

Record audio input:

Binding UI Elements

Simple Binding

The most common pattern is to assign a UI element to a variable and reference it in other cells:

Forms

Prevent updates until a submit button is clicked:
Forms are useful when you have multiple related inputs and want to batch their updates. Without a form, each slider change would trigger re-execution. With a form, changes only apply when submitted.

Batch

Group multiple UI elements together:

Dictionary

Create dictionaries of UI elements:

Array

Create arrays of UI elements:

Interactive Charts

Altair Charts

Make Altair charts interactive:

Plotly Charts

Make Plotly charts interactive:

Matplotlib

Add interactivity to matplotlib plots:

Best Practices

1

Keep UI in separate cells

Create UI elements in their own cells for better organization and reactivity.
2

Use meaningful variable names

Choose descriptive names for UI elements to make your notebook more readable.
3

Use forms for expensive operations

Wrap UI elements in forms when changes trigger expensive computations.
4

Leverage batch and dictionary

Group related UI elements using batch() or dictionary() for cleaner code.
All UI elements support common parameters like label, on_change, disabled, and full_width for consistent styling and behavior.