Tabs

class marimo.ui.tabs(tabs: dict[str, object], value: str | None = None, lazy: bool = False, *, label: str = '', on_change: Callable[[str], None] | None = None)

Display objects in a tabbed view.

Examples.

Show content in tabs:

tab1 = mo.vstack([
    "slider": mo.ui.slider(1, 10),
    "text": mo.ui.text(),
    "date": mo.ui.date()
])

tab2 = mo.md("You can show arbitrary content in a tab.")

tabs = mo.ui.tabs({
    "Heading 1": tab1,
    "Heading 2": tab2
})

Control which tab is selected:

tabs = mo.ui.tabs(
    {"Heading 1": tab1, "Heading 2": tab2}, value="Heading 2"
)

Tab content can be lazily loaded:

tabs = mo.ui.tabs(
    {"Heading 1": tab1, "Heading 2": expensive_component}, lazy=True
)

Attributes.

  • value: A string, the name of the selected tab.

Initialization Args.

  • tabs: a dictionary of tab names to tab content; strings are interpreted as markdown

  • value: the name of the tab to open; defaults to the first tab

  • lazy: a boolean, whether to lazily load the tab content. This is a convenience that wraps each tab in a mo.lazy component.

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.