Tabs
Tabs allows the user to switch between content sections.
Overview
Tabs are primarily used to switch between panels of content, therefore, if you are using more than three tabs, it may be more appropriate to consider an Accordion. Tabs are based on the Card component and have similar behaviour in terms of elevation. They can be used in place of a Card, or inside a Card as an inline component.
Usage
Tabs are a combination of components that are composed together. Linking the tabs to panels is taken care of by the Tabs component.
Content
Tab content should be related content that is separated into, at most, a few sections. Ideally, no more than 3-4 tabs should be used. Tabs should be checked on a small device to ensure content can comfortably fit.
Content should not flow from one tab to another or be used to compare content as only one panel of content can be viewed at a time.
Accessibility
Keyboard Navigation
Similar to Radio Field, tabs can be navigated with the left and right arrow keys (opens in new window) . This will select a new tab and change the content to the corresponding panel. The active tab will be the only tabbable element, so the user can easily tab to other elements on the page.
Variations
Full Width
Tabs by default will be responsive and displayed as full width below the smallest breakpoint. You can override this by setting fullWidth="always" and fullWidth="never".
Inline
Like Cards, tabs that are placed inside of a raised component can be flattened by using adding the inline property.
Controlled
Tabs can be manually controlled using onSelected and defaultSelected in combination.
Properties
Tabs
Name | Values | Default |
---|---|---|
defaultSelectedAn zero based index of the active tab | Number | |
onSelectedA callback function that will receive the selected tab index | Function | |
fullWidth | alwaysneversmall | small |
inline | Boolean | false |
... | JSX.IntrinsicElements["div"] |
TabList
Name | Values | Default |
---|---|---|
... | JSX.IntrinsicElements["ul"] |
Tab
Name | Values | Default |
---|---|---|
onClickCalled in addition to selecting a tab. e.g. analytics | Function | |
... | JSX.IntrinsicElements["li"] |
TabPanel
Name | Values | Default |
---|---|---|
... | JSX.IntrinsicElements["section"] |
Tokens
Tabs will inherit the Card tokens for its spacing, but additional tokens can be overriden.