Tabs
A tabs component lets you tab between content.
#
ImportTabs
: The component that provides the context to the other components.Tabs.Menu
: Wrapper forTabs.Tab
. Keeps track of the currently selected tab.Tabs.Tab
: The individual tab button used to navigate between tabs.Tabs.Panels
: Wrapper forTabs.Panel
. Keeps track of the currently selected panel.Tabs.Panel
: The individual panel. This is where your content goes.
#
UsageSyntaxError: Unexpected token (1:8) 1 : return () ^
#
PropscolorScheme
#
Use the colorScheme
prop to change the colors of the tabs. You can use one of the built-in schemes, or pass a list of class names to create your own.
SyntaxError: Unexpected token (1:8) 1 : return () ^
direction
#
You can choose the direction of the tabs by using the direction
prop. It can be either horizontal
or vertical
. It defaults to horizontal
.
SyntaxError: Unexpected token (1:8) 1 : return () ^
variant
#
You can choose the style of the tabs by using the variant
prop. It can be either underline
or pills
. It defaults to underline
.
SyntaxError: Unexpected token (1:8) 1 : return () ^
isFitted
#
You can make the tabs take up the full width by passing the isFitted
prop. This only works when the direction
is set to horizontal
(that's the default).
SyntaxError: Unexpected token (1:8) 1 : return () ^
isLazy
#
If you don't want to render the children of the panels unless it's active you can use the isLazy
prop.
SyntaxError: Unexpected token (1:8) 1 : return () ^
#
Controlled modeThe tabs component is stateful by default, but can easily be turned in to a controlled component by passing the index
and onChange
props.
SyntaxError: Unexpected token (1:8) 1 : return () ^
#
AccessabilityTabs
follows the practices for tabs found at WAI-ARIA Authoring Practices.
- Only the active tab is allowed focus.
- Tabbing from the tab gives focus to the current tab panel.
- Using the arrow keys navigates the between tabs.
Home
andEnd
navigates to the start and end of the tabs.Tabs.Panel
has the role oftabpanel
.Tabs.Menu
has the role oftablist
.Tabs.Tab
has the role oftab
.Tabs.Panel
hasaria-hidden
when not selected.Tabs.Panel
hasaria-labelledby
set to the id of theTabs.Tab
with the same index.