Search

Find a component, token or page

Base · Navigation

Tabs

Switches between related views in the same space.

HTML / JSDraftReactStableReact NativeDraftSwift (SwiftUI)PlannedGodotPlannedVueDraftSvelteDraftSolidDraft
Reviewed
Rotterdam to Chicago, arriving Thursday.

Props

tsx
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"

<Tabs defaultValue="overview">
  <TabsList>
    <TabsTrigger value="overview">Overview</TabsTrigger>
    <TabsTrigger value="tracking">Tracking</TabsTrigger>
    <TabsTrigger value="documents">Documents</TabsTrigger>
  </TabsList>
  <TabsContent value="overview">…</TabsContent>
  <TabsContent value="tracking">…</TabsContent>
  <TabsContent value="documents">…</TabsContent>
</Tabs>

Overview

Tabs split content into peer sections and show one at a time. Switching is instant and keeps the person on the same page.

When to use

  • To organise related content into two to six peer sections.
  • When people need to switch back and forth without losing their place.

When not to use

  • For steps that must happen in order: use a stepper.
  • To move between pages of the app: use navigation.
  • To filter one list: use Toggle Group.

Anatomy

  1. Tabs

    The root. Owns which tab is selected.

  2. List

    The row of triggers.

  3. Trigger

    One tab. The selected trigger is raised (default) or underlined (line).

  4. Content

    The panel for the selected tab.

Props

The contract every language implements. Names follow each language’s conventions (camelCase in React, snake_case in Rust).

PropTypeDefaultDescription
variant"default" | "line"defaultSegmented control or underlined tabs. Set on the list.
orientation"horizontal" | "vertical"horizontalDirection of the tab list. (React, Rust (Dioxus), HTML / JS only)
defaultValuestring–The tab selected at first.
onValueChangefunction–Called with the newly selected tab’s value.

States

Selected
Raised surface (default) or brand underline (line).
Unselected
Muted text; hover brings it to full contrast.
Focus-visible
Ring in color.border.focus on the focused trigger.
Disabled
A disabled trigger is dimmed and skipped by arrow keys.

Accessibility

Role: tablist, tab, tabpanel

KeysAction
TabMoves focus to the selected tab, then into its panel.
Arrow Left/Arrow RightMoves to the previous or next tab (Arrow Up / Arrow Down when vertical).
Home/EndMoves to the first or last tab.
  • Each panel is labelled by its tab.
  • Keep labels to one or two words so the list never wraps.

Design tokens

Change any of these in Foundations and this component follows, in every language.

Platform notes

HTML / JS
Draft
Buttons with role="tab" and panels with role="tabpanel"; pdc.js handles clicks, arrow keys, Home and End, aria-selected and hiding the other panels. `orientation` goes on the root, `variant` on the list.
React
Stable
Matches the contract with no platform differences.
React Native
Draft
Horizontal only: vertical tab lists do not suit phone screens. The list scrolls sideways when it overflows.
Swift (SwiftUI)
Planned
Not built in Swift yet.
Godot
Planned
Not built in Godot yet.
Vue
Draft
Usage snippet only; same props and behavior as the React component.
Svelte
Draft
Usage snippet only; same props and behavior as the React component.
Solid
Draft
Usage snippet only; same props and behavior as the React component.

Related