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.
Live Demo
Section titled “Live Demo”You can check the Tabs widget directly in this interactive example:
Call mr.Tabs() with a list of tab labels.
The function returns one output widget for each tab.
Basic Example
Section titled “Basic Example”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")Set Active Tab
Section titled “Set Active Tab”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")Layout Position
Section titled “Layout Position”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")Tabs Props
Section titled “Tabs Props”labels
Section titled “labels”type: list[str]
Labels displayed in the tab header. Each label creates one tab and one output panel.
active
Section titled “active”type: int
Index of the initially active tab (0-based).
The default is 0.
position
Section titled “position”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.