Tab
Create toggleable content panes using any of our navigation or list group components.
Tabs supports navigation styles such as variant="tabs" and variant="pills", as well as a variant="list-group" presentation.
Nav tab
Give Tabs a unique id, then add Tab children with an eventKey and label. The component creates matching tab controls and content panes, including their accessibility attributes.
Tabs forwards the Nav layout and styling props fill, justified, vertical,
cardHeader, and navbar to the tab list. vertical also enables vertical keyboard
navigation; an explicit orientation takes precedence. These Nav-only props do not
affect the list-group variant.
This is some placeholder content the Home tab’s associated content.
<Stack gap={3}>
<Tabs
id="myTab"
variant="tabs"
>
<Tab
eventKey="home"
label="Home"
>
<p>
This is some placeholder content the{' '}
<strong>
Home tab’s
</strong>
{' '}associated content.
</p>
</Tab>
<Tab
eventKey="profile"
label="Profile"
>
<p>
This is some placeholder content the{' '}
<strong>
Profile tab’s
</strong>
{' '}associated content.
</p>
</Tab>
<Tab
eventKey="contact"
label="Contact"
>
<p>
This is some placeholder content the{' '}
<strong>
Contact tab’s
</strong>
{' '}associated content.
</p>
</Tab>
<Tab
disabled
eventKey="disabled"
label="Disabled"
>
<p>
This is some placeholder content the{' '}
<strong>
Disabled tab’s
</strong>
{' '}associated content.
</p>
</Tab>
</Tabs>
</Stack>With buttons
Tabs use button controls rather than navigation links. Tabs renders the tab list and its tablist role on an inner element, and generates the button controls.
<Stack gap={3}>
<Tabs
fill
id="nav-tab2"
variant="tabs"
>
<Tab
eventKey="home"
label="Home"
>
<p>
This is some placeholder content the{' '}
<strong>
Home tab’s
</strong>
{' '}associated content.
</p>
</Tab>
<Tab
eventKey="profile"
label="Profile"
>
<p>
This is some placeholder content the{' '}
<strong>
Profile tab’s
</strong>
{' '}associated content.
</p>
</Tab>
<Tab
eventKey="contact"
label="Contact"
>
<p>
This is some placeholder content the{' '}
<strong>
Contact tab’s
</strong>
{' '}associated content.
</p>
</Tab>
<Tab
disabled
eventKey="disabled"
label="Disabled"
>
<p>
This is some placeholder content the{' '}
<strong>
Disabled tab’s
</strong>
{' '}associated content.
</p>
</Tab>
</Tabs>
</Stack>Pills
The tabs plugin also works with pills.
This is some placeholder content the Home tab’s associated content.
<Stack gap={3}>
<Tabs
id="pills-tab"
justified
variant="pills"
>
<Tab
eventKey="home"
label="Home"
>
<p>
This is some placeholder content the{' '}
<strong>
Home tab’s
</strong>
{' '}associated content.
</p>
</Tab>
<Tab
eventKey="profile"
label="Profile"
>
<p>
This is some placeholder content the{' '}
<strong>
Profile tab’s
</strong>
{' '}associated content.
</p>
</Tab>
<Tab
eventKey="contact"
label="Contact"
>
<p>
This is some placeholder content the{' '}
<strong>
Contact tab’s
</strong>
{' '}associated content.
</p>
</Tab>
<Tab
disabled
eventKey="disabled"
label="Disabled"
>
<p>
This is some placeholder content the{' '}
<strong>
Disabled tab’s
</strong>
{' '}associated content.
</p>
</Tab>
</Tabs>
</Stack>And with vertical pills. Set vertical to give the tab list the corresponding layout,
aria-orientation, and keyboard behavior.
This is some placeholder content the Home tab’s associated content.
<Tabs
className="d-flex align-items-start gap-4"
id="v-pills-tab"
variant="pills"
vertical
>
<Tab
eventKey="home"
label="Home"
>
<p>
This is some placeholder content the{' '}
<strong>
Home tab’s
</strong>
{' '}associated content.
</p>
</Tab>
<Tab
eventKey="profile"
label="Profile"
>
<p>
This is some placeholder content the{' '}
<strong>
Profile tab’s
</strong>
{' '}associated content.
</p>
</Tab>
<Tab
disabled
eventKey="disabled"
label="Disabled"
>
<p>
This is some placeholder content the{' '}
<strong>
Disabled tab’s
</strong>
{' '}associated content.
</p>
</Tab>
<Tab
eventKey="messages"
label="Messages"
>
<p>
This is some placeholder content the{' '}
<strong>
Messages tab’s
</strong>
{' '}associated content.
</p>
</Tab>
<Tab
eventKey="settings"
label="Settings"
>
<p>
This is some placeholder content the{' '}
<strong>
Settings tab’s
</strong>
{' '}associated content.
</p>
</Tab>
</Tabs>List groups
Use Tabs with variant="list-group" for a list-group presentation. Add Tab children as usual; the component generates the controls and corresponding content panels.
Some placeholder content in a paragraph relating to "Home".
<Stack gap={3}>
<Tabs
className="d-grid gap-4 _listTabs_1w73o_53"
id="list-tab"
orientation="vertical"
variant="list-group"
>
<Tab
eventKey="home"
label="Home"
>
<p>
Some placeholder content in a paragraph relating to "Home".
</p>
</Tab>
<Tab
eventKey="profile"
label="Profile"
>
<p>
Some placeholder content in a paragraph relating to "Profile".
</p>
</Tab>
<Tab
eventKey="messages"
label="Messages"
>
<p>
Some placeholder content in a paragraph relating to "Messages".
</p>
</Tab>
<Tab
eventKey="settings"
label="Settings"
>
<p>
Some placeholder content in a paragraph relating to "Settings".
</p>
</Tab>
</Tabs>
</Stack>Accessibility
Dynamic tabbed interfaces, as described in the ARIA Authoring Practices Guide tabs pattern, require tab roles and additional aria- attributes to convey their structure and current state. Tabs generates these attributes and uses buttons for controls that switch content rather than navigate to another page.
In line with the ARIA Authoring Practices pattern, only the currently active tab receives keyboard focus. Tabs sets tabIndex={-1} on inactive controls. Once the active tab has focus, the cursor keys activate the previous/next tab. The Home and End keys activate the first and last enabled tabs, respectively. The component changes the roving tabindex accordingly: horizontal lists use Left/Right, while vertical lists use Up/Down.
In general, to facilitate keyboard navigation, it’s recommended to make the tab panels themselves focusable as well.
TabssuppliestabIndex={0}for each panel.
The tab JavaScript plugin does not support tabbed interfaces that contain menus, as these cause both usability and accessibility issues. From a usability perspective, the fact that the currently displayed tab’s trigger element is not immediately visible (as it’s inside the closed menu) can cause confusion. From an accessibility point of view, there is currently no sensible way to map this sort of construct to a standard WAI ARIA pattern, meaning that it cannot be easily made understandable to users of assistive technologies.
Usage
Use defaultActiveKey for the initially selected tab, or activeKey with onChange for a controlled selection. Disabled tabs cannot be activated and are skipped during keyboard navigation.
Fade effect
Content panes fade in by default. The pane you leave hides immediately, because two in-flow panes cannot cross-fade without one stacking under the other. Set fade={false} to switch the fade off.
<Tabs id="instant-tabs" defaultActiveKey="home" fade={false}>
<Tab eventKey="home" label="Home">
Home content
</Tab>
<Tab eventKey="profile" label="Profile">
Profile content
</Tab>
</Tabs>
Events
Use onChange(eventKey) to respond to selection changes instead of registering Bootstrap plugin events.