Tabs

Web/Mobile

A set of layered sections of content, known as tab panels, displayed one at a time.

نام، ایمیل و تصویر نمایه خود را از این بخش تغییر دهید.

Installation

pnpm dlx cubix-ui@latest add tabs --base aria

Usage

Import
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/cubix/tabs"
Example
<Tabs defaultValue="account" className="w-full max-w-md">
  <TabsList aria-label="تنظیمات حساب">
    <TabsTrigger value="account">حساب کاربری</TabsTrigger>
    <TabsTrigger value="password">رمز عبور</TabsTrigger>
  </TabsList>
  <TabsContent value="account" className="rounded-lg border p-4 text-muted-foreground">
    نام، ایمیل و تصویر نمایه خود را از این بخش تغییر دهید.
  </TabsContent>
  <TabsContent value="password" className="rounded-lg border p-4 text-muted-foreground">
    برای امنیت بیشتر، رمز عبور خود را هر چند ماه یک بار عوض کنید.
  </TabsContent>
</Tabs>

Composition

Every TabsTrigger is paired with a TabsContent that has the same value. Tabs start right-to-left and follow the closest dir on the page; pass dir to override it.

Structure
Tabs
├── TabsList
│   └── TabsTrigger (value)
└── TabsContent (value)

Accessibility

The list renders role="tablist", each trigger role="tab" with aria-selected, and each panel role="tabpanel" linked to its tab. Name the list with aria-label. The list is a single tab stop and arrow keys follow the reading direction. Removable tabs announce their Delete and Backspace shortcuts through aria-keyshortcuts.

KeyAction
TabMoves focus into the list onto the active tab, then out to the active panel.
ArrowLeft / ArrowRightMoves to the next or previous tab in reading direction, so the keys are mirrored in RTL. Selection follows focus.
ArrowUp / ArrowDownMoves to the previous or next tab when orientation is vertical.
Home / EndMoves to the first or last enabled tab.
Delete / BackspaceRemoves the focused tab when it has onRemove. Focus moves to the neighboring tab.

Examples

With icons

Put an icon inside the trigger and mark it with data-icon="inline-start" so spacing follows the reading direction.

اطلاعات عمومی نمایه شما برای اعضای تیم قابل مشاهده است.

Removable

Pass onRemove to a trigger to add a remove control at its end. When the active tab is removed, select its neighbor in the same handler.

۱۲ پیام جدید در صندوق ورودی دارید.

Vertical

Use orientation="vertical" to stack the triggers. The list is placed at the inline start and ArrowUp / ArrowDown move between tabs.

زبان، منطقه زمانی و قالب تاریخ را تنظیم کنید.

Disabled tab

A disabled trigger cannot be selected, and arrow key navigation skips it.

خلاصه وضعیت پروژه در هفته جاری.

Controlled

Pass value and onValueChange to own the active tab, for example to drive it from step buttons.

کالاهای انتخابی خود را بررسی کنید.

Custom styling

Every base marks the active trigger with aria-selected="true", so one set of aria-selected: classes styles it on Base UI, React Aria, and Radix.

شاخص‌های کلیدی این ماه در یک نگاه.

API Reference

Note: Parts render data-slot attributes (tabs, tabs-list, tabs-trigger, tabs-remove, tabs-content) for targeting in tests and parent selectors. Use the same props on Base UI, React Aria, and Radix.

Tabs

PropTypeDefaultDescription
valuestring-Controlled active tab value. Use with `onValueChange`.
defaultValuestring-Default active tab value for uncontrolled usage.
onValueChange(value: string) => void-Called when a tab trigger selects a new value.
dir"ltr" | "rtl"closest dir on the page (rtl if none)The reading direction. It sets the arrow-key direction and where the list sits.
orientation"horizontal" | "vertical""horizontal"The orientation of the tabs list and triggers.
classNamestring-Additional Tailwind classes merged with the root styles.

TabsList

PropTypeDefaultDescription
variant"line""line"The visual style of the tabs list. Tabs are always the underline style; use Segmented Control for a filled pill switcher.
aria-labelstring-Names the group of tabs for screen readers.
classNamestring-Additional Tailwind classes merged with the list styles.

TabsTrigger

PropTypeDefaultDescription
valuestring-The tab value selected by this trigger.
disabledbooleanfalseDisables the trigger and prevents interaction.
onRemove() => void-Adds a remove control at the end of the trigger. Called when it is clicked, or when Delete or Backspace is pressed on the focused tab. Focus moves to the neighboring tab.
classNamestring-Additional Tailwind classes merged with the trigger styles.

TabsContent

PropTypeDefaultDescription
valuestring-The tab value that controls when this panel is shown.
classNamestring-Additional Tailwind classes merged with the content styles.