Skip to main content

An official website of the United States government

Here's how you know

An official website of the United States government

Here's how you know

Theme:

Design system switcher

Version:

Design system switcher

Theme:

Design system switcher

Version:

Design system switcher

Tabs

Tabs are a secondary navigation pattern, allowing a user to view only the content they're interested in. They build upon a real world metaphor, and the selected state simulates a folder being physically in front of others in the group.

Examples

Guidance

When to use

  • If you have sub-sections of a page, and there's the need to only show one sub-section at a time.

When to consider alternatives

  • 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.

Usage

  • 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.

Accessibility

  • Use anchor links (<a>) to create tabs. This allows direct linking, supports progressive enhancement, and preserves default browser behavior like opening tabs in a new window.
    Note: You’ll need to implement logic to select the appropriate tab based on the current URL.
  • Markup should include proper ARIA roles and attributes to ensure accessibility:
    • Each tab (<a>):
      role="tab", aria-selected, aria-controls
    • Tablist container:
      role="tablist", aria-label (not applied by default — use the ariaLabel prop.)
    • Each tab panel:
      role="tabpanel", aria-labelledby
Notice:

Use Tabs and TabPanel Together

When you use our Tabs and TabPanel components together, ARIA roles are handled automatically. The Tabs component sets the appropriate aria-controls and manages selection state, while TabPanel sets its own role and receives a generated tabId. We recommend using both components together to ensure accessibility is correctly implemented.

Accessibility testing

Keyboard navigation

  • Users should be able to navigate to each tab using the Tab key and navigate backwards using Shift + Tab.
  • Pressing Enter should activate the focused tab.
  • When a tab has focus, arrow keys (/) should move focus between tabs.
  • A visible focus indicator should clearly show which tab is currently focused or selected.

Screen reader

Our Tabs component applies the correct semantic roles (tablist, tab, and tabpanel) to ensure proper screen reader support. When implemented correctly, screen readers announce:

  • The label for each tab which is derived by the tab prop on each TabPanel.
  • Its role (e.g., "tab").
  • Its position within the set (e.g., "Tab 1 of 3").
  • Whether the tab is selected.

Zoom magnification

To ensure tab content remains visible when the screen is magnified, the widths of tabs and tab panels are defined using percentages. As the page is magnified, the height of the tabs increases and content reflows to fit the new dimensions.

Code

React

Review Storybook for React guidance of this component.

Web Component

Go to Storybook for Web Component guidance of this component.

Style customization

The following CSS variables can be overridden to customize Tab components:

CSS variables for tabs
VariableDefault Core Theme Value
--tabs__border-colorhex value: #d9d9d9--color-border
--tabs__background-colorhex value: #ffffff--color-background
--tabs__background-color--selectedhex value: #ffffff--color-background
--tabs__background-color--hoverhex value: #ffffff--color-background
--tabs__background-color--disabledhex value: #d9d9d9--color-gray-lighter
--tabs__border-color--selectedhex value: #0071bc--color-primary
--tabs__border-color--disabledhex value: #d9d9d9--color-gray-lighter
--tabs__colorhex value: #262626--color-base
--tabs__color--hoverhex value: #0071bc--color-primary
--tabs__color--selectedhex value: #0071bc--color-primary
--tabs-panel__background-colorhex value: #ffffff--color-background
--tabs__color--activehex value: #004f84--color-primary-darker
--tabs__color--disabledhex value: #404040--color-gray-darker

Learn more

Component maturity

For more information about how we tested and validated our work for each checklist item, read our component maturity documentation.

Accessibility

  • Color

    Meets AA color contrast standards for accessibility and color blindness.
    Complete
  • Forced Colors Mode (FCM)

    While using FCM the components text is legible and improves readability.
    Complete
  • WCAG 2.1 Level AA Conformance

    All Axe checks for WCAG AA compliance have passed.
    Complete
  • Screen readers

    VoiceOver, NVDA, and JAWS screen readers provide concise communication and interaction.
    Complete
  • Keyboard navigation

    Component is fully navigable with a keyboard.
    Complete

Code

  • Storybook

    Component has stories to cover all defined props.
    Complete
  • Responsive

    Component designed to work in all responsive breakpoints.
    Incomplete
  • Spanish translations

    Includes Spanish translations for default text content.
    Not applicable

Tokens

  • Code

    Tokens implemented in code.
    Complete
  • Design

    Tokens implemented in Figma.
    Incomplete