Skip to main content

Overview

The Tabs component creates a tabbed interface where you can organize content into separate, switchable views. Each tab is created using the Tab component nested within Tabs.

Basic usage

Parameters

Tabs

int | str | None
default:"None"
The currently selected tab. Can be updated to switch tabs programmatically. Uses the index (int) or label (str) of the tab.
bool
default:"True"
If False, tabs will be hidden.
str | None
default:"None"
An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
list[str] | str | None
default:"None"
An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
bool
default:"True"
If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.

Tab

str
The label of the tab.
int | str | None
default:"None"
An optional identifier for the tab. If provided, this will be used instead of the label when updating the selected tab.
str | None
default:"None"
An optional string that is assigned as the id of this component in the HTML DOM.
list[str] | str | None
default:"None"
An optional list of strings that are assigned as the classes of this component in the HTML DOM.
bool
default:"True"
If False, this tab will be hidden.
bool
default:"True"
If False, this tab cannot be selected.

Behavior

Programmatic tab switching

You can switch tabs programmatically using the selected parameter:

Examples

Multi-step form

Create a wizard-style interface:

Different input modes

Let users choose between different input methods:

Conditional tab visibility

Show or hide tabs based on user input:

Tab selection event

Respond when a user switches tabs:

Nested tabs

Create hierarchical organization:

Model comparison

Compare outputs from different models:

Events

select

Triggered when a tab is selected:

Methods

update

Update the Tabs component properties:

Notes

Use the id parameter on Tab components when you need to reference specific tabs programmatically. This is more stable than using labels, which might change.
Tabs are great for reducing visual clutter in complex interfaces. Group related functionality together to keep your UI clean and organized.
The select event provides access to the selected tab’s information through gr.SelectData, which includes the tab’s value (label or id).