Tabs is a container component that manages the state of your tabs for you. In most cases, you'll want to use this component rather than the presentational components (
TabPanel) on their own.
Must only contain
Sets the initial selected
A callback function that's invoked when the selected tab is changed.
Additional classes to be added to the component wrapping the tabs
TabPanel is a presentational component which accepts a tab's content as its
Additional classes to be added to the root element.
The associated tab's label. Only applicable when the panel is a
Additional classes for the associated tab. Only applicable when the panel
is a child of
The associated tab's
The following Sass variables can be overridden to customize Tab components:
- If you have sub-sections of a page, and there's the need to only show one sub-section at a time.
- If you have more than four tabs. Consider using a different pattern if your content requires being split into more than four panels.
- If the panel contents can be displayed at once. This will improve the scanability of your page's content and it's more likely the user will be able to find what they're looking for. Typography, including clear section headers, should be enough to allow the user to navigate the page.
- Avoid overflowing tabs to new lines. If the tabs can't fit on one row on small screens, consider using utility classes to apply additional responsive styles or use a different pattern.
- Tab labels should be descriptive of their content and set the user's expectations.
- Tab labels should be short — aim for no more than two words.
- Use an anchor link (
a) to create the tabs. This allows you to link directly to a tab, and allows you to progressively enhance the page, retaining default browser behavior like opening links in a new window. Note: You'll need to implement the logic for selecting the correct tab based on the current URL.
- Ensure the HTML markup includes the proper ARIA attributes:
- For tabs:
- For the tabs list parent:
- For a tab panel:
- For tabs: