Components
Tabs
Tabs are used to navigate between related pages or views while retaining context.
Best Practices
Icons should be used sparingly in tab buttons to reduce space and visual noise of the tab bar.
Accessibility
The Tabs component follows the WAI-ARIA Tabs Pattern for accessible tab interfaces.
Keyboard Navigation:
- The expected keyboard navigation for tabs is for the user to be able to tab into the tab group and then use the arrow key (left and right) to switch tabs
- Switching tabs with the keyboard automatically moves focus to the next tab
Left Arrow: Moves focus to the previous tab, wrapping to the last tab if on the firstRight Arrow: Moves focus to the next tab, wrapping to the first tab if on the lastTab: Moves focus out of the tab group to the next focusable element
ARIA Attributes:
- Tab buttons have
role="tab",aria-selected, andaria-controlsattributes - Tab panels have
role="tabpanel"andaria-labelledbyattributes - The tab list container has
role="tablist"
Tab Panel Usage:
- When using
Tabs.Panel, ensure the panel'sidmatches its corresponding tab button'sid - This establishes the proper relationship between tabs and panels for screen readers
- Tab panels should be conditionally rendered based on the selected tab