Skip to main content

mo.ui.table

Display data in an interactive, searchable table.

Signature

mo.ui.table(
    data: Sequence[dict[str, Any]] | dict[str, Sequence[Any]],
    selection: Literal["single", "multi"] | None = None,
    pagination: bool = True,
    page_size: int = 10,
    *,
    label: str = "",
    on_change: Callable[[list[dict[str, Any]]], None] | None = None
)

Parameters

data
Sequence[dict] | dict[str, Sequence]
required
Table data as list of dicts or dict of lists
selection
'single' | 'multi'
Enable row selection (single or multiple)
pagination
bool
default:"True"
Enable pagination
page_size
int
default:"10"
Number of rows per page
label
str
default:"''"
Markdown label for the table

Examples

import marimo as mo

# Basic table
data = [
    {"name": "Alice", "age": 30, "city": "NYC"},
    {"name": "Bob", "age": 25, "city": "SF"},
    {"name": "Charlie", "age": 35, "city": "LA"},
]

table = mo.ui.table(data)
table
# Table with selection
selectable_table = mo.ui.table(
    data,
    selection="multi",
    label="**Select rows:**"
)

mo.md(f"Selected: {selectable_table.value}")
# Column-oriented data
data_cols = {
    "Name": ["Alice", "Bob", "Charlie"],
    "Age": [30, 25, 35],
    "City": ["NYC", "SF", "LA"]
}

table = mo.ui.table(data_cols, page_size=5)
For dataframe-specific features, use mo.ui.dataframe() instead.

Build docs developers (and LLMs) love