Status

Use progress bars or spinners to visualize loading status in your notebooks and apps. Useful when iterating over collections or loading data from files, databases, or APIs.

Progress bar

You can display a progress bar while iterating over a collection, similar to tqdm.

marimo.status.progress_bar(collection: Collection[S | int] | None = None, *, title: str | None = None, subtitle: str | None = None, completion_title: str | None = None, completion_subtitle: str | None = None, total: int | None = None, show_rate: bool = True, show_eta: bool = True, remove_on_exit: bool = False)

Iterate over a collection and show a progress bar

Example.

for i in mo.status.progress_bar(range(10)):
    ...

You can optionally provide a title and subtitle to show during iteration, and a title/subtitle to show upon completion.

You can also use progress_bar with a context manager and manually update the bar:

with mo.status.progress_bar(total=10) as bar:
    for i in range(10):
        ...
        bar.update()

The update method accepts the optional keyword arguments increment (defaults to 1), title, and subtitle.

For performance reasons, the progress bar is only updated in the UI every 150ms.

Args.

  • collection: optional collection to iterate over

  • title: optional title

  • subtitle: optional subtitle

  • completion_title: optional title to show during completion

  • completion_subtitle: optional subtitle to show during completion

  • total: optional total number of items to iterate over

  • show_rate: if True, show the rate of progress (items per second)

  • show_eta: if True, show the estimated time of completion

  • remove_on_exit: if True, remove the progress bar from output on exit

Spinner

marimo.status.spinner(title: str | None = None, subtitle: str | None = None, remove_on_exit: bool = True)

Show a loading spinner

Use mo.status.spinner() as a context manager to show a loading spinner. You can optionally pass a title and subtitle.

Example.

with mo.status.spinner(subtitle="Loading data ...") as _spinner:
    data = expensive_function()
    _spinner.update(subtitle="Crunching numbers ...")
    ...

mo.ui.table(data)

You can also show the spinner without a context manager:

mo.status.spinner(title="Loading ...") if condition else mo.md("Done!")

Args:

  • title: optional title

  • subtitle: optional subtitle

  • remove_on_exit: if True, the spinner is removed from output on exit