Tabs may be used navigate between multiple URLs. Tabs are intended as page-level navigation - if you're looking at just switching panels of content, please use SegmentedControl.

Props

Component props
Name
Type
Default
activeTabIndex
Required
number
-
onChange
Required
({| +event: SyntheticMouseEvent<> | SyntheticKeyboardEvent<>, +activeTabIndex: number, dangerouslyDisableOnNavigation: () => void |}) => void
-

If your app uses a tool such as react-router to navigate between pages, be sure to use onChange to navigate instead of getting a full page refresh with href

tabs
Required
Array<{| href: string, text: React.Node, id?: string, indicator?: "dot" | number, ref?: {| current: ?HTMLElement |} |}>
-
bgColor
"default" | "transparent"
"default"

If Tabs is displayed in a container with a colored background, use this prop to remove the white tab background. See the background color example to learn more.

wrap
boolean
-

By default, flex items will all try to fit onto one line. Use this prop to allow the items to wrap onto multiple lines, from top to bottom.

Usage guidelines

When to Use
  • To break up a large collection of content into logical, digestible views.
  • To switch between different, yet related views, such as Updates and Messages.
When Not to Use
  • When any UI or content above the Tabs is altered upon selection. Use Link instead.
  • To break up content that is not related to each other or is not on the same hierarchical level.

Best practices

Do

Place Tabs directly above the target content.

Don't

Use Tabs as a way to filter content. Consider using SegmentedControl in this use-case.

Do

Keep Tab labels concise, ideally one to two words.

Don't

Truncate labels in Tabs. If there is not enough horizontal space, allow the Tabs to scroll horizontally.

Do

Order Tabs by relevance — the first tab should be the most logical starting view. Ideally, sequence Tabs by association — tabs with similar content should be adjacent to each other.

Don't

Disable or hide Tabs if a Tab's content is empty. There should always be at least 2 Tabs. We don't support applying a disabled state for the Tab as it can cause usability and accessibility issues.

Accessibility

Tabs are intended for page-level navigation between multiple URLs. Each tab must have an individual title that precisely describes the tab content. Provide a short, descriptive label for screen-readers using accessibilityLabel. It is helpful for users of assistive technologies so they have the necessary information to navigate the content efficiently.

Keyboard

Tab key navigates the tabs.
Enter/return key activates a tab (i.e., it navigates to the link href).

Screen Reader

The tab/link must announce a state of "current" if the href matches the current window URL.

Localization

Be sure to localize text and accessibilityLabel.
The Tab's title should be 3 words or less: long enough to be understood by users but short enough to prevent text wrapping. Aim for a single word when possible.

Example

Background color

Link
Link is used to navigate to different areas of the product or to external sites. Link is the preferred component in cases where you want to direct the user to unrelated content.

SegmentedControl
SegmentedControl is used to switch between views within a small area of content, such as a Popover. SegmentedControl is preferred when changing state or selection within a view.