<Tabs> Component

General purpose tabs component. Used heavily across all websites, but especially heavily on Learn.

Share
Code Editor

Where it's used

0.x.x
Loading 0.x.x releases...
1.x.x
Loading 1.x.x releases...
2.x.x
Loading 2.x.x releases...
3.x.x
Loading 3.x.x releases...
4.x.x
Loading 4.x.x releases...
5.x.x
Loading 5.x.x releases...
6.x.x
Loading 6.x.x releases...

Props

NameDescription
defaultTabIdx
integer
If set, the tab with the specified ID will be active by default. If not set or if the ID does not match, it will default to 0
centered
boolean
If true, the tabs are centered in their container, rather than left-aligned
fullWidthBorder
boolean
If true, the border line underneath the tabs expands to the full width of the container, rather than being slightly padded from the edges
onChange
function
Optional callback which is executed when a new tab is selected. Passed (newTabIndex, groupId).
children*
React.ReactNode
Data to be displayed as tabs
Object contains nested props, see below:
children.heading
string
Title of the tab
children.tooltip
string
Optional tooltip to be displayed next to the tab title
children.group
string
A unique identifier for a tab 'group' that, when active, all Tabs with this id will become active when one is selected. Note it's necessary to wrap the page with TabProvider for this feature to function.

Examples

A bunch of tabs

Share
Code Editor

With tooltips!

Share
Code Editor

With an onChange handler

Share
Code Editor

With Tab Groups

First, second and third tabs should be actively synced based on their matching group property. Note the TabProvider must wrap the page where this component is used for 'groups' to function properly.

Share
Code Editor
Share
Code Editor