The CoreUI React Tabs component provides a flexible and accessible way to create tabbed navigation in your application. It supports various styles and configurations to meet different design requirements.
Available in Other JavaScript Frameworks
CoreUI React Tab Component is also available for Angular and Vue. Explore framework-specific implementations below:
Example
The basic React tabs example uses the variant="tabs" props to generate a tabbed interface.
import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsExample = () => {
return (
<CTabs defaultActiveItemKey="profile">
<CTabList variant="tabs">
<CTab itemKey="home">Home</CTab>
<CTab itemKey="profile">Profile</CTab>
<CTab itemKey="contact">Contact</CTab>
<CTab disabled itemKey="disabled">
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" itemKey="home">
Home tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="profile">
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="contact">
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="disabled">
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsExample = () => {
return (
<CTabs defaultActiveItemKey="profile">
<CTabList variant="tabs">
<CTab itemKey="home">Home</CTab>
<CTab itemKey="profile">Profile</CTab>
<CTab itemKey="contact">Contact</CTab>
<CTab disabled itemKey="disabled">
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" itemKey="home">
Home tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="profile">
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="contact">
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="disabled">
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}Available styles
Change the style of <CTabs>’s component with modifiers and utilities. Mix and match as needed, or build your own.
Unstyled
If you don’t provide the variant prop, the component will default to a basic style.
import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsUnstyledExample = () => {
return (
<CTabs defaultActiveItemKey="profile">
<CTabList>
<CTab itemKey="home">Home</CTab>
<CTab itemKey="profile">Profile</CTab>
<CTab itemKey="contact">Contact</CTab>
<CTab disabled itemKey="disabled">
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" itemKey="home">
Home tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="profile">
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="contact">
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="disabled">
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsUnstyledExample = () => {
return (
<CTabs defaultActiveItemKey="profile">
<CTabList>
<CTab itemKey="home">Home</CTab>
<CTab itemKey="profile">Profile</CTab>
<CTab itemKey="contact">Contact</CTab>
<CTab disabled itemKey="disabled">
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" itemKey="home">
Home tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="profile">
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="contact">
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="disabled">
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}Pills
Take that same code, but use variant="pills" instead:
import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsPillsExample = () => {
return (
<CTabs defaultActiveItemKey={2}>
<CTabList variant="pills">
<CTab aria-controls="home-tab-pane" itemKey={1}>
Home
</CTab>
<CTab aria-controls="profile-tab-pane" itemKey={2}>
Profile
</CTab>
<CTab aria-controls="contact-tab-pane" itemKey={3}>
Contact
</CTab>
<CTab aria-controls="disabled-tab-pane" disabled itemKey={4}>
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" aria-labelledby="home-tab-pane" itemKey={1}>
Home tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="profile-tab-pane" itemKey={2}>
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="contact-tab-pane" itemKey={3}>
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="disabled-tab-pane" itemKey={4}>
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsPillsExample = () => {
return (
<CTabs defaultActiveItemKey={2}>
<CTabList variant="pills">
<CTab aria-controls="home-tab-pane" itemKey={1}>
Home
</CTab>
<CTab aria-controls="profile-tab-pane" itemKey={2}>
Profile
</CTab>
<CTab aria-controls="contact-tab-pane" itemKey={3}>
Contact
</CTab>
<CTab aria-controls="disabled-tab-pane" disabled itemKey={4}>
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" aria-labelledby="home-tab-pane" itemKey={1}>
Home tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="profile-tab-pane" itemKey={2}>
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="contact-tab-pane" itemKey={3}>
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="disabled-tab-pane" itemKey={4}>
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}Underline
Take that same code, but use variant="underline" instead:
import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsUnderlineExample = () => {
return (
<CTabs defaultActiveItemKey={2}>
<CTabList variant="underline">
<CTab aria-controls="home-tab-pane" itemKey={1}>
Home
</CTab>
<CTab aria-controls="profile-tab-pane" itemKey={2}>
Profile
</CTab>
<CTab aria-controls="contact-tab-pane" itemKey={3}>
Contact
</CTab>
<CTab aria-controls="disabled-tab-pane" disabled itemKey={4}>
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" aria-labelledby="home-tab-pane" itemKey={1}>
Home tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="profile-tab-pane" itemKey={2}>
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="contact-tab-pane" itemKey={3}>
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="disabled-tab-pane" itemKey={4}>
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsUnderlineExample = () => {
return (
<CTabs defaultActiveItemKey={2}>
<CTabList variant="underline">
<CTab aria-controls="home-tab-pane" itemKey={1}>
Home
</CTab>
<CTab aria-controls="profile-tab-pane" itemKey={2}>
Profile
</CTab>
<CTab aria-controls="contact-tab-pane" itemKey={3}>
Contact
</CTab>
<CTab aria-controls="disabled-tab-pane" disabled itemKey={4}>
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" aria-labelledby="home-tab-pane" itemKey={1}>
Home tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="profile-tab-pane" itemKey={2}>
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="contact-tab-pane" itemKey={3}>
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="disabled-tab-pane" itemKey={4}>
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}Underline border
Take that same code, but use variant="underline-border" instead:
import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsUnderlineBorderExample = () => {
return (
<CTabs defaultActiveItemKey={2}>
<CTabList variant="underline-border">
<CTab aria-controls="home-tab-pane" itemKey={1}>
Home
</CTab>
<CTab aria-controls="profile-tab-pane" itemKey={2}>
Profile
</CTab>
<CTab aria-controls="contact-tab-pane" itemKey={3}>
Contact
</CTab>
<CTab aria-controls="disabled-tab-pane" disabled itemKey={4}>
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" aria-labelledby="home-tab-pane" itemKey={1}>
Home tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="profile-tab-pane" itemKey={2}>
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="contact-tab-pane" itemKey={3}>
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="disabled-tab-pane" itemKey={4}>
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsUnderlineBorderExample = () => {
return (
<CTabs defaultActiveItemKey={2}>
<CTabList variant="underline-border">
<CTab aria-controls="home-tab-pane" itemKey={1}>
Home
</CTab>
<CTab aria-controls="profile-tab-pane" itemKey={2}>
Profile
</CTab>
<CTab aria-controls="contact-tab-pane" itemKey={3}>
Contact
</CTab>
<CTab aria-controls="disabled-tab-pane" disabled itemKey={4}>
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" aria-labelledby="home-tab-pane" itemKey={1}>
Home tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="profile-tab-pane" itemKey={2}>
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="contact-tab-pane" itemKey={3}>
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" aria-labelledby="disabled-tab-pane" itemKey={4}>
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}Enclosed
Use the variant="enclosed" class to give your navigation items a subtle border and rounded styling.
import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsEnclosedExample = () => {
return (
<CTabs defaultActiveItemKey="profile">
<CTabList variant="enclosed">
<CTab itemKey="home">Home</CTab>
<CTab itemKey="profile">Profile</CTab>
<CTab itemKey="contact">Contact</CTab>
<CTab disabled itemKey="disabled">
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" itemKey="home">
Home tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="profile">
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="contact">
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="disabled">
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsEnclosedExample = () => {
return (
<CTabs defaultActiveItemKey="profile">
<CTabList variant="enclosed">
<CTab itemKey="home">Home</CTab>
<CTab itemKey="profile">Profile</CTab>
<CTab itemKey="contact">Contact</CTab>
<CTab disabled itemKey="disabled">
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" itemKey="home">
Home tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="profile">
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="contact">
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="disabled">
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}Enclosed pills
Use the variant="enclosed-pills" to achieve a pill-style appearance for each nav item, using pill-shaped borders and smoother outlines.
import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsEnclosedPillsExample = () => {
return (
<CTabs defaultActiveItemKey="profile">
<CTabList variant="enclosed-pills">
<CTab itemKey="home">Home</CTab>
<CTab itemKey="profile">Profile</CTab>
<CTab itemKey="contact">Contact</CTab>
<CTab disabled itemKey="disabled">
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" itemKey="home">
Home tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="profile">
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="contact">
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="disabled">
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsEnclosedPillsExample = () => {
return (
<CTabs defaultActiveItemKey="profile">
<CTabList variant="enclosed-pills">
<CTab itemKey="home">Home</CTab>
<CTab itemKey="profile">Profile</CTab>
<CTab itemKey="contact">Contact</CTab>
<CTab disabled itemKey="disabled">
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" itemKey="home">
Home tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="profile">
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="contact">
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="disabled">
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}Fill and justify
Force your <CTabs>’s contents to extend the full available width one of two modifier classes. To proportionately fill all available space use layout="fill". Notice that all horizontal space is occupied, but not every nav item has the same width.
import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsUnstyledFillAndJustifyExample = () => {
return (
<CTabs defaultActiveItemKey={2}>
<CTabList variant="tabs" layout="fill">
<CTab aria-controls="home-tab-pane" itemKey={1}>
Home
</CTab>
<CTab aria-controls="profile-tab-pane" itemKey={2}>
Profile tab with longer content
</CTab>
<CTab aria-controls="contact-tab-pane" itemKey={3}>
Contact
</CTab>
<CTab aria-controls="disabled-tab-pane" disabled itemKey={4}>
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="py-4" aria-labelledby="home-tab-pane" itemKey={1}>
Home tab content
</CTabPanel>
<CTabPanel className="py-4" aria-labelledby="profile-tab-pane" itemKey={2}>
Profile tab content
</CTabPanel>
<CTabPanel className="py-4" aria-labelledby="contact-tab-pane" itemKey={3}>
Contact tab content
</CTabPanel>
<CTabPanel className="py-4" aria-labelledby="disabled-tab-pane" itemKey={4}>
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsUnstyledFillAndJustifyExample = () => {
return (
<CTabs defaultActiveItemKey={2}>
<CTabList variant="tabs" layout="fill">
<CTab aria-controls="home-tab-pane" itemKey={1}>
Home
</CTab>
<CTab aria-controls="profile-tab-pane" itemKey={2}>
Profile tab with longer content
</CTab>
<CTab aria-controls="contact-tab-pane" itemKey={3}>
Contact
</CTab>
<CTab aria-controls="disabled-tab-pane" disabled itemKey={4}>
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="py-4" aria-labelledby="home-tab-pane" itemKey={1}>
Home tab content
</CTabPanel>
<CTabPanel className="py-4" aria-labelledby="profile-tab-pane" itemKey={2}>
Profile tab content
</CTabPanel>
<CTabPanel className="py-4" aria-labelledby="contact-tab-pane" itemKey={3}>
Contact tab content
</CTabPanel>
<CTabPanel className="py-4" aria-labelledby="disabled-tab-pane" itemKey={4}>
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}For equal-width elements, use layout="justified". All horizontal space will be occupied by nav links, but unlike the layout="fill" above, every nav item will be the same width.
import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsUnstyledFillAndJustify2Example = () => {
return (
<CTabs defaultActiveItemKey={2}>
<CTabList variant="tabs" layout="justified">
<CTab aria-controls="home-tab-pane" itemKey={1}>
Home
</CTab>
<CTab aria-controls="profile-tab-pane" itemKey={2}>
Profile
</CTab>
<CTab aria-controls="contact-tab-pane" itemKey={3}>
Contact
</CTab>
<CTab aria-controls="disabled-tab-pane" disabled itemKey={4}>
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="py-4" aria-labelledby="home-tab-pane" itemKey={1}>
Home tab content
</CTabPanel>
<CTabPanel className="py-4" aria-labelledby="profile-tab-pane" itemKey={2}>
Profile tab content
</CTabPanel>
<CTabPanel className="py-4" aria-labelledby="contact-tab-pane" itemKey={3}>
Contact tab content
</CTabPanel>
<CTabPanel className="py-4" aria-labelledby="disabled-tab-pane" itemKey={4}>
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}import React from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsUnstyledFillAndJustify2Example = () => {
return (
<CTabs defaultActiveItemKey={2}>
<CTabList variant="tabs" layout="justified">
<CTab aria-controls="home-tab-pane" itemKey={1}>
Home
</CTab>
<CTab aria-controls="profile-tab-pane" itemKey={2}>
Profile
</CTab>
<CTab aria-controls="contact-tab-pane" itemKey={3}>
Contact
</CTab>
<CTab aria-controls="disabled-tab-pane" disabled itemKey={4}>
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="py-4" aria-labelledby="home-tab-pane" itemKey={1}>
Home tab content
</CTabPanel>
<CTabPanel className="py-4" aria-labelledby="profile-tab-pane" itemKey={2}>
Profile tab content
</CTabPanel>
<CTabPanel className="py-4" aria-labelledby="contact-tab-pane" itemKey={3}>
Contact tab content
</CTabPanel>
<CTabPanel className="py-4" aria-labelledby="disabled-tab-pane" itemKey={4}>
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}Controlled and uncontrolled
The tabs work either way, and the prop you reach for is what picks the mode.
| prop | who owns the active tab | |
|---|---|---|
| Uncontrolled | defaultActiveItemKey | the tabs, from that starting point |
| Controlled | activeItemKey | your component |
onChange fires in both modes with the key of the tab that was picked — so you can watch the state without taking it over.
Uncontrolled
Give the tabs a starting point and let them manage themselves. This is what every example above does.
<CTabs defaultActiveItemKey={2}>Controlled
Pass activeItemKey and the tabs render exactly what you pass — a click only fires onChange. Feed the change back, or nothing moves.
import React, { useState } from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsControlledExample = () => {
const [activeTab, setActiveTab] = useState<number | string>('profile')
return (
<CTabs activeItemKey={activeTab} onChange={setActiveTab}>
<CTabList variant="tabs">
<CTab itemKey="home">Home</CTab>
<CTab itemKey="profile">Profile</CTab>
<CTab itemKey="contact">Contact</CTab>
<CTab disabled itemKey="disabled">
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" itemKey="home">
Home tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="profile">
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="contact">
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="disabled">
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}import React, { useState } from 'react'
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react'
export const TabsControlledExample = () => {
const [activeTab, setActiveTab] = useState('profile')
return (
<CTabs activeItemKey={activeTab} onChange={setActiveTab}>
<CTabList variant="tabs">
<CTab itemKey="home">Home</CTab>
<CTab itemKey="profile">Profile</CTab>
<CTab itemKey="contact">Contact</CTab>
<CTab disabled itemKey="disabled">
Disabled
</CTab>
</CTabList>
<CTabContent>
<CTabPanel className="p-4" itemKey="home">
Home tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="profile">
Profile tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="contact">
Contact tab content
</CTabPanel>
<CTabPanel className="p-4" itemKey="disabled">
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>
)
}Use it when the active tab belongs to something else: a route, a query parameter, or a control outside the tabs.
Accessibility
Dynamic tabbed interfaces, as described in the WAI ARIA Authoring Practices, require role="tablist", role="tab", role="tabpanel", and additional aria- attributes in order to convey their structure, functionality and current state to users of assistive technologies (such as screen readers).
WAI-ARIA Roles
- The element that serves as the container for the set of tabs has the role
tablist. - Each element that serves as a tab has the role
taband is contained within the element with the roletablist. - Each element that contains the content panel for a tab has the role
tabpanel. - If the tab list has a visible label, the element with the role
tablisthasaria-labelledbyset to a value that refers to the labeling element. Otherwise, thetablistelement has a label provided byaria-label. - Each element with the role
tabhas the propertyaria-controlsreferring to its associatedtabpanelelement. - The active tab element has the state
aria-selectedset totrue, and all other tab elements have it set tofalse. - Each element with the role
tabpanelhas the propertyaria-labelledbyreferring to its associatedtabelement.
Our React Tabs component automatically manages all role="..." and aria- attributes for accessibility. It also handles the selected state by adding aria-selected="true" to the active tab. Additionally, you have the flexibility to manually set these attributes, as shown in the example below:
<CTabs defaultActiveItemKey={2}>
<CTabList variant="tabs">
<CTab id="home-tab" aria-controls="home-tab-pane" itemKey={1}>Home</CTab>
<CTab id="profile-tab" aria-controls="profile-tab-pane" itemKey={2}>Profile</CTab>
<CTab id="contact-tab" aria-controls="contact-tab-pane" itemKey={3}>Contact</CTab>
<CTab id="disabled-tab" aria-controls="disabled-tab-pane" disabled itemKey={4}>Disabled</CTab>
</CTabList>
<CTabContent>
<CTabPanel id="home-tab-pane" className="p-4" aria-labelledby="home-tab-pane" aria-labelledby="home-tab" itemKey={1}>
Home tab content
</CTabPanel>
<CTabPanel id="profile-tab-pane" className="p-4" aria-labelledby="profile-tab-pane" aria-labelledby="profile-tab" itemKey={2}>
Profile tab content
</CTabPanel>
<CTabPanel id="contact-tab-pane" className="p-4" aria-labelledby="contact-tab-pane" aria-labelledby="contact-tab" itemKey={3}>
Contact tab content
</CTabPanel>
<CTabPanel id="disabled-tab-pane" className="p-4" aria-labelledby="disabled-tab-pane" aria-labelledby="disabled-tab" itemKey={4}>
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>This example demonstrates how to manually set aria-selected, aria-controls, and aria-labelledby attributes on your <CTab>’s and <CTabPanels>’s.
Keyboard Interaction
When focus enters the tab list:
Tab: It places focus on the active tab element.
When focus is on a tab element:
Tab: Moves focus to the next element in the tab sequence, typically the tabpanel unless the first focusable element inside the tabpanel is found earlier.
Left Arrow: Moves focus to the previous tab. If on the first tab, it wraps around to the last tab.
Right Arrow: Moves focus to the next tab. If on the last tab, it wraps around to the first tab.
Home: Moves focus to the first tab.
End: Moves focus to the last tab.
API
Check out the documentation below for a comprehensive guide to all the props you can use with the components mentioned here.