# Tabs

> A tablist compound with roving-tabindex keyboard navigation, automatic or manual activation, and an accent-underline or segmented visual style.

- Package: `fancy-ui-react` (React 18/19 + Tailwind CSS v4)
- Category: Navigation
- Tags: tabs, tablist, roving-tabindex, compound, navigation
- Types: `TabsProps`, `TabsListProps`, `TabsTriggerProps`, `TabsContentProps`, `TabsContext`
- Docs: https://fancy-ui.rama.app/docs/components/tabs
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/react/src/components/tabs

## Import

```tsx
import { Tabs } from 'fancy-ui-react';
```

Setup (once per project): `npm install fancy-ui-react`, then put these lines in your main CSS file (the stylesheet import goes right after `@import "tailwindcss";`):

```css
@import "tailwindcss";
@import "fancy-ui-react/tailwind.css";
```

and import the component styles once in the app entry: `import "fancy-ui-react/styles.css";`. Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in React; when one differs from the Svelte name, the Svelte name follows in parentheses. `class` becomes `className`, a callback takes the name the React port declares (`onclick` becomes `onClick`), snippets become `ReactNode` props (render functions when they take arguments) and the default snippet is `children`. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/react#divergences-from-the-svelte-api

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string` | `""` | The active tab's value, bindable. |
| `onValueChange` | `(value: string) => void` | — | Called with the new value whenever the active tab changes. |
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | The tablist's stacking axis and which arrow-key pair moves it. |
| `activation` | `"automatic" \| "manual"` | `"automatic"` | Whether arrowing to a trigger selects it immediately, or only moves focus. |
| `variant` | `"underline" \| "segmented"` | `"underline"` | Accent underline, or a segmented pill rail. |
| `className` (Svelte `class`) | `string` | — | Additional CSS classes, merged onto the root. |
| `ref` | `HTMLDivElement \| null` | `null` | Bindable reference to the root element. |
| `sound` | `boolean` | `false` | Plays select when the active tab actually changes, once the user has enabled sound |
| `TabsList.className` (Svelte `TabsList.class`) | `string` | — | Additional CSS classes, merged onto the tablist. |
| `TabsList.ref` | `HTMLDivElement \| null` | `null` | Bindable reference to the tablist element. |
| `TabsTrigger.value` (required) | `string` | — | This trigger's value — which TabsContent it activates. |
| `TabsTrigger.disabled` | `boolean` | `false` | Disables just this trigger; it is skipped by the arrows and Home/End. |
| `TabsTrigger.className` (Svelte `TabsTrigger.class`) | `string` | — | Additional CSS classes, merged onto the trigger button. |
| `TabsTrigger.ref` | `HTMLButtonElement \| null` | `null` | Bindable reference to the trigger's button element. |
| `TabsContent.value` (required) | `string` | — | Which TabsTrigger shows this panel. |
| `TabsContent.forceMount` | `boolean` | `false` | Keeps this panel mounted (with hidden) even while inactive, instead of unmounting it entirely. |
| `TabsContent.className` (Svelte `TabsContent.class`) | `string` | — | Additional CSS classes, merged onto the panel. |
| `TabsContent.ref` | `HTMLDivElement \| null` | `null` | Bindable reference to the panel element. |

## Node props

| Prop | Description |
| --- | --- |
| `children` | A TabsList and one or more TabsContents. |
| `TabsList.children` | The TabsTriggers. |
| `TabsTrigger.children` | The trigger's content, typically the tab's label. |
| `TabsContent.children` | The panel's content. |

## Example

```tsx
import { useState } from "react";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "fancy-ui-react";

export function TabsExample() {
	const [section, setSection] = useState("account");

	return (
		<Tabs sound value={section} onValueChange={setSection}>
			<TabsList>
				<TabsTrigger value="account">Account</TabsTrigger>
				<TabsTrigger value="security">Security</TabsTrigger>
				<TabsTrigger value="billing">Billing</TabsTrigger>
			</TabsList>
			<TabsContent value="account">Manage your profile, name, and avatar.</TabsContent>
			<TabsContent value="security">Update your password and two-factor settings.</TabsContent>
			<TabsContent value="billing">View invoices and update your payment method.</TabsContent>
		</Tabs>
	);
}
```
