Refresh#

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”).

Example.

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

Attributes.

  • 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])

Create a submittable form out of this UIElement.

Inherited from Html

batch(**elements)

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

center()

Center an item.

right()

Right-justify.

left()

Left-justify.

callout([kind])

Create a callout containing this HTML element.

Public Data Attributes:

name

Inherited from UIElement

value

The element’s current value.

Inherited from Html

text

A string of HTML representing this element.