> For AI agents: the complete documentation index is available at https://rickyshin93.github.io/tao-ui/llms.txt, the full documentation bundle is available at https://rickyshin93.github.io/tao-ui/llms-full.txt.

# Tabs

Navigation`@rockshin/tao-ui`

[Examples](#examples)[API](#api)

Switches between peer panels within the same page context.

## When to use

Use Tabs to separate peer views without navigating away from the current task.

**Recommended**

- Use short tab labels.
- Keep tab panels at comparable hierarchy.

**Avoid**

- Do not use Tabs for sequential steps.

## Examples


### Basic usage
```tsx preview
import { Tabs } from '@rockshin/tao-ui';

function TabsExample() {
  return (
    <Tabs
      items={[
        { key: 'general', label: 'General', children: 'General settings.' },
        { key: 'security', label: 'Security', children: 'Security settings.' },
        { key: 'billing', label: 'Billing', children: 'Billing settings.' },
      ]}
    />
  );
}

export default TabsExample;
```

### Card variant and sizes
```tsx preview
import { Stack, Tabs } from '@rockshin/tao-ui';

const items = [
  { key: 'general', label: 'General', children: 'General settings.' },
  { key: 'security', label: 'Security', children: 'Security settings.' },
];

function TabVariants() {
  return (
    <Stack gap="lg">
      <Tabs items={items} size="small" />
      <Tabs items={items} variant="card" size="medium" />
      <Tabs items={items} variant="card" size="large" />
    </Stack>
  );
}

export default TabVariants;
```

### Controlled and disabled tabs
```tsx preview
import { Tabs } from '@rockshin/tao-ui';
import { useState } from 'react';

function ControlledTabs() {
  const [activeKey, setActiveKey] = useState('general');

  return (
    <Tabs
      activeKey={activeKey}
      onChange={setActiveKey}
      items={[
        { key: 'general', label: 'General', children: 'General settings.' },
        { key: 'security', label: 'Security', children: 'Security settings.' },
        {
          key: 'billing',
          label: 'Billing',
          children: 'Unavailable.',
          disabled: true,
        },
      ]}
    />
  );
}

export default ControlledTabs;
```

### Externally controlled tabs
Use `activeKey` and `onChange` to keep tab selection in application state.
```tsx preview
import { Stack, Tabs } from '@rockshin/tao-ui';

import { useState } from 'react';

const basicItems = [
  { key: 'general', label: 'General', children: 'General settings content.' },
  {
    key: 'security',
    label: 'Security',
    children: 'Security settings content.',
  },
  {
    key: 'notifications',
    label: 'Notifications',
    children: 'Notification preferences.',
  },
];

export default function TabsControlled() {
  function Demo() {
    const [key, setKey] = useState('security');
    return (
      <Stack gap="md">
        <Tabs items={basicItems} activeKey={key} onChange={setKey} />
        <p style={{ color: 'var(--tao-color-text-secondary)', fontSize: 13 }}>
          activeKey: {key}
        </p>
      </Stack>
    );
  }
  return <Demo />;
}
```

### Disabled tabs
Disable unavailable content while leaving other tabs interactive.
```tsx preview
import { Tabs } from '@rockshin/tao-ui';

export default function TabsDisabledTab() {
  return (
    <Tabs
      items={[
        { key: 'a', label: 'Active', children: 'This tab works.' },
        { key: 'b', label: 'Also Active', children: 'This too.' },
        {
          key: 'c',
          label: 'Disabled',
          children: 'Cannot reach.',
          disabled: true,
        },
      ]}
    />
  );
}
```

### Card tab sizes
Compare card tabs at different sizes and densities.
```tsx preview
import { Stack, Tabs } from '@rockshin/tao-ui';

const basicItems = [
  { key: 'general', label: 'General', children: 'General settings content.' },
  {
    key: 'security',
    label: 'Security',
    children: 'Security settings content.',
  },
  {
    key: 'notifications',
    label: 'Notifications',
    children: 'Notification preferences.',
  },
];

export default function TabsCardSizes() {
  return (
    <Stack gap="lg">
      <div>
        <p
          style={{
            fontSize: 13,
            color: 'var(--tao-color-text-secondary)',
            marginBottom: 8,
          }}
        >
          small
        </p>
        <Tabs items={basicItems} variant="card" size="small" />
      </div>
      <div>
        <p
          style={{
            fontSize: 13,
            color: 'var(--tao-color-text-secondary)',
            marginBottom: 8,
          }}
        >
          medium
        </p>
        <Tabs items={basicItems} variant="card" size="medium" />
      </div>
      <div>
        <p
          style={{
            fontSize: 13,
            color: 'var(--tao-color-text-secondary)',
            marginBottom: 8,
          }}
        >
          large
        </p>
        <Tabs items={basicItems} variant="card" size="large" />
      </div>
    </Stack>
  );
}
```

### Provider size and local overrides
Inherit the provider size and explicitly override an individual tab group when needed.
```tsx preview
import { Tabs, TaoProvider } from '@rockshin/tao-ui';

const basicItems = [
  { key: 'general', label: 'General', children: 'General settings content.' },
  {
    key: 'security',
    label: 'Security',
    children: 'Security settings content.',
  },
  {
    key: 'notifications',
    label: 'Notifications',
    children: 'Notification preferences.',
  },
];

export default function TabsProviderInherit() {
  return (
    <TaoProvider size="large">
      <Tabs items={basicItems} variant="card" />
    </TaoProvider>
  );
}
```

### Unmount inactive panels
Compare preserved and unmounted panels by editing content before switching tabs.
```tsx preview
import { Tabs } from '@rockshin/tao-ui';

export default function TabsDestroyInactive() {
  return (
    <Tabs
      items={[
        {
          key: 'a',
          label: 'Tab A',
          children: 'Only this panel is in DOM when active.',
        },
        { key: 'b', label: 'Tab B', children: 'Destroyed when not active.' },
        {
          key: 'c',
          label: 'Tab C',
          children: 'Also destroyed when not active.',
        },
      ]}
      destroyInactiveTabPane
    />
  );
}
```

## API


### [#](#tabs)Tabs



| Property | Description | Type | Default Value |
| --- | --- | --- | --- |
| className | Additional css class | `string | undefined` | `-` |

