Skip to content

Tabs

The Tabs helper lets you organize content into multiple tabs, showing one panel at a time. It is useful for dashboards, comparisons, multi-step outputs, or grouping related results without cluttering the UI.

mr.Tabs() returns a tuple of output areas — one per tab.

You can check the Tabs widget directly in this interactive example:

🚀 Load interactive demo Hover to start

Call mr.Tabs() with a list of tab labels. The function returns one output widget for each tab.

Code

import mercury as mr
tabs = mr.Tabs(labels=["Overview", "Details", "Logs"])
with tabs[0]:
print("Overview content")
with tabs[1]:
print("Detailed results")
with tabs[2]:
print("Logs and debug output")

Use the active argument to select which tab is visible initially.

Code

import mercury as mr
tabs = mr.Tabs(
labels=["Train", "Validate", "Test"],
active=1
)
with tabs[1]:
print("Validation results")

Use the position argument to control where the tabs are rendered. The default is position="inline".

Available values:

  • "sidebar" — render tabs in the sidebar
  • "inline" — render tabs in the main notebook flow (default)
  • "bottom" — render tabs after all notebook cells

Code

mr.Tabs(
labels=["Settings", "Preview"],
position="sidebar"
)

type: list[str]

Labels displayed in the tab header. Each label creates one tab and one output panel.


type: int

Index of the initially active tab (0-based). The default is 0.


type: "sidebar" | "inline" | "bottom"

Controls where the tabs container is rendered:

  • sidebar — in the sidebar
  • inline — directly in the notebook output (default)
  • bottom — after all notebook cells

type: string

Unique identifier used to distinguish tabs with identical arguments.


  • mr.Tabs() returns a tuple of output widgets.
  • Write content into a tab using with tabs[i]: ....
  • Only one tab panel is visible at a time.
  • Tabs automatically handle keyboard navigation (arrow keys, Home, End).
  • Content inside tabs is responsive and constrained to the container width.