Tabs
Tabs are a navigation element resembling tabbed dividers in a filing cabinet - by clicking a tab, users can easily locate a page containing related content.
Example
Default tabs
Basic toggle tabs
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Distinctio inventore commodi iure at doloribus architecto sed animi cumque fuga quod exercitationem iste consequatur similique molestiae ab, rerum amet quam laboriosam?
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Info toggle tabs
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Distinctio inventore commodi iure at doloribus architecto sed animi cumque fuga quod exercitationem iste consequatur similique molestiae ab, rerum amet quam laboriosam?
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Anatomy
Default tabs
- Icon (situational): Used as a supporting element for the tab, giving more context to the nature of the tab label.
- Label: Used to inform the user what the tab is about. Should always be short and to the point. Should always be centered.
Basic toggle tabs
- Icon (situational): Used as a supporting element for the tab, giving more context to the nature of the tab label.
- Label: Used to inform the user what the tab is about. Should always be short and to the point. Should always be centered.
- Number count (situational): Used as a supporting element to the tab. E.g number of notifications.
Info toggle tabs
Unlike the other 2 tabs, info toggle tabs are more locked down in design and interaction. It should be used as it is with change in color the only exception.
- Icon (situational): Used as a supporting element for the tab, giving more context to the nature of the tab label.
- Label: Used to inform the user what the tab is about. Should always be short and to the point. Should always be centered.
- Number count (situational): Used as a supporting element to the tab. E.g number of users.
Spacing
Default tabs
Within the default tabs
Ensure that there is at least 8px of vertical spacing between the text and indicator taking into account line height.
Basic toggle tabs
Within the toggle tabs
Ensure that there is at least 16px of horizontal spacing and vertical spacing within the tab.
Info toggle tabs
Within the info toggle tabs
Ensure that there is at least 12px of horizontal and vertical spacing within the tab and 8px vertical spacing between the lable and number count.
Usage guidelines
Best practices:
- As a general rule, the first label for the tabs should align with the grid and the text below. If tabs are within another component, such as a card, follow the grid that you are using inside the component and align the label with text in the component.
- As tabs hide content, it is best to use them sparingly although they do help to save space. Do consider if the content can be displayed upfront instead of being in a tab. In some cases, having too may tabs on a page may cause it to load slowly.
Tabs should be used when:
- You want to expose simliar but separate content.
- You can separate the content into clearly labelled sections.
- You want to expose simliar but separate content.
Tabs should not be used when:
- You want to display critical information to the user, content like this should always be displayed upfront.
- You require users to read the content in a specific order, e.g a step by step guide.
- Users will need to compare information in the different tabs.
Usability guidelines
Keep labels concise
As there will be multiple tabs, it is best to keep labels as short and to the point as possible. This is particularly helpful for users of assistive technologies so they have the necessary information to efficiently navigate the content.
Behaviour
To differentiate an active tab from an inactive tab, apply an underline and colour change to the active tab’s text and icon. Tab behaviour during standard, focus, hover, and active states are important because it lets users know where they are in the experience.
Accessibility guidelines
Aria attributes
-
The element that serves as the container for the set of tabs has
role="tablist"
. -
Each element that serves as a tab has
role="tab"
and is contained within the element withrole="tablist"
. -
Each element that contains the content panel for a
tab
hasrole="tabpanel"
. -
If the tab list has a visible label, the element with
role="tablist"
hasaria-labelledby
set to a value that refers to the labelling element. Otherwise, thetablist
element has a label provided byaria-label
. -
Each element with role
tab
has the propertyaria-controls
referring to its associatedtabpanel
element. -
The active
tab
element has the statearia-selected="true"
and all othertab
elements have it set tofalse
. -
Each element with
role="tabpanel"
has the propertyaria-labelledby
referring to its associatedtab
element.
Keyboard accessibility
For the tab list- Tab when focus moves into the tab list, places focus on the first tab element.
- ←, ↑ moves focus to the previous tab. If focus is on the first tab, moves focus to the last tab. This also activates the newly focused tab.
- ← moves focus to the next tab. If focus is on the last tab element, moves focus to the first tab. This also activates the newly focused tab.
Focus indicator
- Ensure all tab elements (the tabs and the tab panels) can receive keyboard focus.
- Provide a clear focus indicator such as using different font or background colours for the focused tab.
- Move focus to the active tab when it is selected.
- Ensure screen readers announce the active tab and the associated panel.
Tabs design tokens
Last updated 02 October 2024