Components
Tabs
Tabs allow users to navigate between related sections of content, with only one section visible at a time. This is an effective way to organize and present related content on the same page.
React
const Preview = () => { return ( <Tabs defaultValue='value1'> <Tabs.List> <Tabs.Tab value='value1'>Tab 1</Tabs.Tab> <Tabs.Tab value='value2'>Tab 2</Tabs.Tab> <Tabs.Tab value='value3'>Tab 3</Tabs.Tab> </Tabs.List> <Tabs.Panel value='value1'>content 1</Tabs.Panel> <Tabs.Panel value='value2'>content 2</Tabs.Panel> <Tabs.Panel value='value3'>content 3</Tabs.Panel> </Tabs> ); }; render(<Preview />)
Use Tabs when
- content needs to be structured without loading a new page
- information benefits from being divided into clearly labelled sections
- navigation becomes easier when users do not need to view all content at once
Avoid using Tabs when
- it is important to give an immediate overview of the content
- information needs to be compared across sections
- users must go through a step-by-step process where the order matters
- large amounts of content may slow down the page
- the content could just as well be shown on a single page or spread across several pages
Example
Icons only
Tabs can be displayed with icons only for a more compact layout.
Ensure that the icons are intuitive and have descriptive titles for screen readers.
In the example below, we wrap Tabs.Tab in a Tooltip to provide descriptive text for the icons.
React
const IconsOnlyEn = () => { return ( <Tabs defaultValue='car'> <Tabs.List> <Tooltip content='Your cars'> <Tabs.Tab value='car'> <CarIcon title='Car' /> </Tabs.Tab> </Tooltip> <Tooltip content='Your bicycles'> <Tabs.Tab value='bicycle'> <BicycleIcon title='Bicycle' /> </Tabs.Tab> </Tooltip> <Tooltip content='Your motorcycles'> <Tabs.Tab value='motorcycle'> <MotorcycleIcon title='Motorcycle' /> </Tabs.Tab> </Tooltip> </Tabs.List> <Tabs.Panel value='car'> You have no items of this type registered with us </Tabs.Panel> <Tabs.Panel value='bicycle'> You have no items of this type registered with us </Tabs.Panel> <Tabs.Panel value='motorcycle'> You have no items of this type registered with us </Tabs.Panel> </Tabs> ); }; render(<IconsOnlyEn />)
Icons with text
Combining icons with text provides both a visual and textual description of the content.
Icons should be decorative and marked with aria-hidden.
React
const IconsWithTextEn = () => { return ( <Tabs defaultValue='car'> <Tabs.List> <Tabs.Tab value='car'> <CarIcon aria-hidden='true' /> Cars </Tabs.Tab> <Tabs.Tab value='bicycle'> <BicycleIcon aria-hidden='true' /> Bicycles </Tabs.Tab> <Tabs.Tab value='motorcycle'> <MotorcycleIcon aria-hidden='true' /> Motorcycles </Tabs.Tab> </Tabs.List> <Tabs.Panel value='car'> You have no items of this type registered with us </Tabs.Panel> <Tabs.Panel value='bicycle'> You have no items of this type registered with us </Tabs.Panel> <Tabs.Panel value='motorcycle'> You have no items of this type registered with us </Tabs.Panel> </Tabs> ); }; render(<IconsWithTextEn />)
Guidelines
Tabs are used to organise related content into separate sections.
Alternatives to Tabs
Before choosing Tabs, consider whether it might be better to:
- simplify and reduce the amount of content
- distribute the content across several pages
- keep everything on a single page with clear headings
- use a table of contents for easier navigation
Best practice
- Limit the number of
Tabs- too many make it difficult to get an overview, especially on small screens - Use clear, descriptive names -
Tabshide content, so it must be obvious what each section contains - Place the most important content first - organise
Tabsaccording to users’ needs - Keep
Tabson a single line - long labels or too manyTabsmake navigation harder - Avoid disabled
Tabs- remove them or explain why they contain no content
Text
Tabs labels should be short and descriptive so users can easily understand what they will find when clicking.
If it is difficult to create clear labels, it may indicate that the content is not well structured.
If additional context is needed, a shared heading can be placed above the Tabs component.
This can act as an overall description, giving users a quick overview of what the Tabs contain.