# Tabs

Accessible tabbed panels built on Radix Tabs with roving-focus keyboard navigation, horizontal or vertical orientation, and automatic or manual activation.

- Category: Overlays & Navigation
- License: MIT
- Page: https://www.saasuji.com/components/tabs
- Install: npx shadcn@latest add https://www.saasuji.com/r/tabs.json

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| value (Tabs) | `string` | — | Controlled value of the active tab. |
| defaultValue (Tabs) | `string` | — | Value of the tab selected on first render. |
| onValueChange (Tabs) | `(value: string) => void` | — | Called when the active tab changes. |
| orientation (Tabs) | `"horizontal" | "vertical"` | `"horizontal"` | Layout direction that also controls which arrow keys move focus. |
| activationMode (Tabs) | `"automatic" | "manual"` | `"automatic"` | Whether a focused tab activates immediately or on Enter/Space. |
| dir (Tabs) | `"ltr" | "rtl"` | — | Reading direction used for arrow-key navigation. |
| loop (TabsList) | `boolean` | `true` | Wraps keyboard focus from the last tab back to the first. |
| value (TabsTrigger, TabsContent) | `string` | — | Identifies which trigger controls which content panel; required on both. |
| disabled (TabsTrigger) | `boolean` | `false` | Prevents the tab from being activated or focused. |
| forceMount (TabsContent) | `true` | — | Keeps the panel mounted while hidden for animation libraries. |
| asChild (TabsTrigger) | `boolean` | `false` | Renders the trigger as its child element instead of the default button. |
| className (TabsList, TabsTrigger, TabsContent) | `string` | — | Additional classes merged onto the part that receives it. |
| children (all parts) | `React.ReactNode` | — | TabsList with triggers on the root, and the matching panel content inside each TabsContent. |
| ...props (TabsList) | `React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>` | — | All remaining Radix list props are forwarded. |
| ...props (TabsTrigger, TabsContent) | `React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger> | React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>` | — | All remaining Radix trigger and content props are forwarded to the rendered elements. |

## Source

```tsx
"use client"

import * as React from "react"
import * as TabsPrimitive from "@radix-ui/react-tabs"

import { cn } from "@/lib/utils"

const Tabs = TabsPrimitive.Root

const TabsList = React.forwardRef<
    React.ElementRef<typeof TabsPrimitive.List>,
    React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
>(({ className, ...props }, ref) => (
    <TabsPrimitive.List
        ref={ref}
        className={cn(
            "inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
            className
        )}
        {...props}
    />
))
TabsList.displayName = TabsPrimitive.List.displayName

const TabsTrigger = React.forwardRef<
    React.ElementRef<typeof TabsPrimitive.Trigger>,
    React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
>(({ className, ...props }, ref) => (
    <TabsPrimitive.Trigger
        ref={ref}
        className={cn(
            "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",
            className
        )}
        {...props}
    />
))
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName

const TabsContent = React.forwardRef<
    React.ElementRef<typeof TabsPrimitive.Content>,
    React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
>(({ className, ...props }, ref) => (
    <TabsPrimitive.Content
        ref={ref}
        className={cn(
            "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
            className
        )}
        {...props}
    />
))
TabsContent.displayName = TabsPrimitive.Content.displayName

export { Tabs, TabsList, TabsTrigger, TabsContent }

```
