Control flow

Use mo.stop to halt execution of a cell, and optionally output an object. This function is useful for validating user input.

marimo.stop(predicate: bool, output: object | None = None) None

Stops execution of a cell when predicate is True

When predicate is True, this function raises a MarimoStopError. If uncaught, this exception stops execution of the current cell and makes output its output. Any descendants of this cell that were previously scheduled to run will not be run, and their defs will be removed from program memory.


mo.stop(form.value is None,"**Submit the form to continue.**"))


When predicate is True, raises a MarimoStopError.

class marimo.MarimoStopError(output: object | None)

Raised by marimo.stop to stop execution of a cell and descendants.

Inherits from BaseException to prevent accidental capture with except Exception (similar to KeyboardInterrupt)

Use mo.ui.refresh to trigger other cells to run periodically, on a configurable interval (or on click).

class marimo.ui.refresh(options: list[Union[int, float, str]] | None = None, default_interval: int | float | str | None = None, *, label: str = '', on_change: Callable[[int], None] | None = None)

A refresh button that will auto-refresh its descendants for a given interval.

Each option value can either be a number (int or float) in seconds or a human-readable string (e.g. “1s”, “10s”, “1m”).

You can also combine multiple time units (e.g. “1m 30s”).

Note: The refresh interval may not be exact, as it depends on the time it takes to render the content and the time it takes to send the content to the client. Also, due to the buffering of UI element changes, if the downstream cells take a long time to render, the refresh interval may be longer than expected.


refresh_button = mo.ui.refresh(
    options=["1m", "5m 30s", "10m"],


  • value: The time in seconds since the refresh has been activated.

Initialization Args.

  • options: The options for the refresh interval, as a list of human-readable strings or numbers (int or float) in seconds. If no options are provided and default_interval is provided, the options will be generated automatically. If no options are provided and default_interval is not provided, the refresh button will not be displayed with a dropdown for auto-refresh.

  • default_interval: The default value of the refresh interval.

  • label: optional text label for the element

  • on_change: optional callback to run when this element’s value changes

Public methods

Inherited from UIElement

form([label, bordered, loading, ...])

Create a submittable form out of this UIElement.

send_message(message, buffers)

Send a message to the element rendered on the frontend from the backend.

Inherited from Html


Convert an HTML object with templated text into a UI element.


Center an item.






Create a callout containing this HTML element.


Wrap an object in a styled container.

Public Data Attributes:


Inherited from UIElement


The element’s current value.

Inherited from Html


A string of HTML representing this element.