Run Button

class marimo.ui.run_button(kind: Literal['neutral', 'success', 'warn', 'danger'] = 'neutral', disabled: bool = False, tooltip: str | None = None, *, label: str = 'click to run', on_change: Callable[[Any], None] | None = None, full_width: bool = False)

A button that can be used to trigger computation.

Example.

# a button that when clicked will have its value set to True;
# any cells referencing that button will automatically run.
button = mo.ui.run_button()
button
slider = mo.ui.slider(1, 10)
slider
# if the button hasn't been clicked, don't run.
mo.stop(not button.value)

slider.value

When clicked, run_button’s value is set to True, and any cells referencing it are run. After those cells are run, run_button’s value will automatically be set back to False as long as automatic execution is enabled.

Attributes.

  • value: the value of the button; True when clicked, and reset to False after cells referencing the button finish running (when automatic execution is enabled).

Initialization Args.

  • kind: ‘neutral’, ‘success’, ‘warn’, or ‘danger’

  • disabled: whether the button is disabled

  • tooltip: a tooltip to display for the button

  • label: text label for the element

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

  • full_width: whether the input should take up the full width of its container

Public methods

Inherited from UIElement

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

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.

style(style)

Wrap an object in a styled container.

Public Data Attributes:

Inherited from UIElement

value

The element’s current value.

Inherited from Html

text

A string of HTML representing this element.