Skip to content

Tabs

Move between related views without leaving the page.

The big picture.

Installation

Terminal
pnpm dlx shadcn@latest add \
  https://react-toolbox.io/r/tabs.json \
  https://react-toolbox.io/r/input.json

New here? Set up your project first. Styles, fonts, and required components are included. The command includes the components used by the examples below.

Usage

Each Tab provides a stable string value, its label, and panel content. Arrow keys move between enabled tabs.

Composition

Stable values support custom trigger wrappers and reordered tabs. activationMode="manual" separates arrow-key focus from selection; forceMount preserves the draft.

Show composition code
tsx
'use client';
import { TabsRoot, TabsList, TabsTrigger, TabsIndicator, TabsContent } from '@/components/ui/material/tabs';
import { Input } from '@/components/ui/material/input';

function ProfileTab() {
  return <TabsTrigger value="profile">Profile</TabsTrigger>;
}
export default function TabsComposition() {
  return (
    <TabsRoot defaultValue="profile" activationMode="manual">
      <TabsList aria-label="Account settings">
        <ProfileTab />
        <TabsTrigger value="notifications">Notifications</TabsTrigger>
        <TabsTrigger value="billing" disabled>
          Billing
        </TabsTrigger>
        <TabsIndicator />
      </TabsList>
      <TabsContent value="profile" forceMount>
        <Input label="Persistent draft" defaultValue="Javi" />
      </TabsContent>
      <TabsContent value="notifications">Choose how you receive updates.</TabsContent>
      <TabsContent value="billing">Billing settings</TabsContent>
    </TabsRoot>
  );
}

State and callbacks

  • Tabs accepts value/onValueChange or defaultValue. Each tab and panel has a stable string value. Keyboard focus activates tabs by default; activationMode="manual" waits for Enter or Space.
  • Inactive content unmounts by default. Use hideMode="display" to preserve child state, or forceMount on TabsContent in the composition API.

API reference

Key props and defaults. Full types and inline documentation are included with the source in material/tabs.

Tabs

Property Type Default
activationMode 'automatic' | 'manual'

Manual activation keeps expensive panels unchanged until Enter or Space.

'automatic'
defaultValue string

Initial selection when value is not controlled.

—
fixed boolean false
hideMode 'display' | 'unmounted' 'unmounted'
loop boolean true
onValueChange (value: string) => void —
value string —

Tab

Property Type Default
label ReactNode —
valueRequired string

Stable selection value shared by the tab and its panel.

—

TabContent

Property Type Default
valueRequired string

Stable selection value shared by the tab and its panel.

—

Material guidelines

  • Group related peer views. Use short, centered labels and an indicator to identify the selected view; tabs should not submit actions.
  • Keep labels concise and centered. M1 text-only tabs are 48px high, with minimum widths of 72px on small screens and 160px on larger screens.
  • The fixed option deliberately shares all available width, overriding the default width bounds. Prefer short, single-line labels; automatic two-line label sizing is not provided.

Material Design 1: Tabs