Components / Tabs
Tabs
One view at a time. Square, monospaced tabs for related panels, with Radix selection, meaningful tab relationships and visible keyboard focus.
Storybook runs locally or as a separate build; no hosted Storybook is configured. Source and setup links match the install revision.
Usage playground
Switch workspace views with the keyboard or pointer. Compare automatic selection on focus with manual activation using Enter or Space. Access starts unavailable; enable it below.
Selected view: overview
'use client';
import { useState } from 'react';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/yads-tabs';
export default function WorkspaceTabsExample() {
Installation
pnpm dlx [email protected] add biehlio/yet-another-design-system/tabs#e7b31d0e0c9d8b24d53e97ca38b3b68d345e9f40Run this revision-pinned command in a shadcn-configured React project. It installs yads-tabs.tsx, its scoped stylesheet, Radix Tabs and JetBrains Mono. No consumer Tailwind, global reset, theme variables or provider is required. Light is standalone; a containing .dark class selects dark colors.
Import { Tabs, TabsList, TabsTrigger, TabsContent } from @/components/ui/yads-tabs, adjusting the alias to your project. Copy sample always includes a complete client module and recipe styles, even while collapsed. Samples use inline layout styles, not Tailwind utilities.
The account example separately imports YADS Card, Label, Input and Button. Install the card, label, input and button registry items at the same revision by replacing tabs in the command above. The retained draft needs only Label and Input in addition to Tabs. These are example companions, not dependencies of the Tabs primitive.
Account settings
Uncontrolled selection starts with defaultValue="account". Each panel composes Card, Label, Input and Button into a separate form. Labels use unique IDs; native constraints still apply. Submissions report locally and send nothing. Switching away resets unsaved uncontrolled fields because panel children unmount.
Account details
'use client';
import { useId, useState } from 'react';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/yads-tabs';
import { Input } from '@/components/ui/yads-input';
import { Label } from '@/components/ui/yads-label';
Panel mounting and state
By default, inactive panel wrappers remain hidden but their children unmount: local state and uncontrolled input edits reset on return. Keep important values above Tabs in controlled state, or opt individual panels into forceMount. This example keeps both panels mounted; scoped CSS hides inactive panels from layout, keyboard and the accessibility tree. Effects in force-mounted children keep running. Hidden enabled form controls may still submit if placed in a shared form; use separate forms or manage disabled explicitly.
'use client';
import { useId } from 'react';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/yads-tabs';
import { Input } from '@/components/ui/yads-input';
import { Label } from '@/components/ui/yads-label';
className customization
Ordinary CSS can change the active color and trigger border without removing keyboard outlines. This vertical, manual example also sets loop=false: focus stops at each end. The complete copied module includes the recipe. Keep a single row or column when practical; wrapping on narrow screens does not change arrow-key order.
'use client';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/yads-tabs';
export default function CustomTabsExample() {
return <>
Accessibility
- Name the views. Label TabsList and use descriptive visible trigger text. Radix supplies tablist, tab and tabpanel roles, aria-selected, aria-controls and aria-labelledby. Keep unique matching values and do not override generated IDs or relationships independently.
- One stop in the tablist. Tab enters on the selected trigger (or the current roving stop), then leaves the list for the active panel and its controls. Disabled triggers are skipped. Panel containers are focusable by default; keep the visible outline.
- Follow the arrow axis. Left/Right move between horizontal triggers (reversed in RTL); Up/Down move between vertical triggers. Home/End focus the first/last enabled trigger. Focus wraps unless loop=false. In manual mode focus alone does not change selection; Enter or Space activates it. Pointer selection works in either mode.
- Use automatic mode for instant panels. Tabs adds no loading, data fetching, URL synchronization or navigation framework. Use manual activation when selecting would be expensive, and manage any loading or focus announcements in your application. Use links for navigation to separate pages.
- Keep selection valid. If a selected view becomes disabled or is removed, choose an enabled value in your application. Disabling a trigger does not automatically repair controlled selection. Name and label controls inside panels independently.
Active tabs use a filled background and border, not color alone; keyboard focus has a separate 2px outline in both themes. Inactive force-mounted panels stay hidden via scoped CSS, but their effects and form controls still exist.
API reference
Import the four parts and TabsProps, TabsListProps, TabsTriggerProps or TabsContentProps from @/components/ui/yads-tabs. Each type is derived from the corresponding Radix part. There are no YADS variants or routing props.
On narrow screens, focus the table and scroll horizontally to read all columns.
| Part | Prop | Type | Default | Description |
|---|---|---|---|---|
Tabs | value / defaultValue | string | Not set | Controlled selection with value + onValueChange, or uncontrolled initial defaultValue. Supply a matching value; no tab is selected automatically when neither is set. |
Tabs | onValueChange | (value: string) => void | Not set | Called on selection changes. Update controlled value synchronously; do not mix value and defaultValue or switch ownership. |
Tabs | orientation | 'horizontal' | 'vertical' | horizontal | Changes layout, aria-orientation and the arrow-key axis. |
Tabs | activationMode | 'automatic' | 'manual' | automatic | Automatic selects on focus; manual requires Enter, Space or a pointer press. |
Tabs | dir | 'ltr' | 'rtl' | ltr | Sets text direction and horizontal keyboard navigation. Set explicitly for RTL; do not rely only on CSS direction. |
TabsList | aria-label / aria-labelledby | string | Not set | Give the tablist a meaningful accessible name. |
TabsList | loop | boolean | true | Wrap arrow focus at the first/last enabled trigger. false stops at the ends. |
TabsTrigger | value | string (required) | None | Unique within this Tabs root and exactly matches its TabsContent value. Radix generates trigger/panel IDs and relationships. |
TabsTrigger | disabled | boolean | false | Native disabled button: cannot activate and is skipped by roving focus. Root has no disabled prop. |
TabsContent | value | string (required) | None | Matches a trigger. Renders a focusable tabpanel labeled by that trigger. |
TabsContent | forceMount | true | undefined | undefined | Keeps children mounted; YADS scoped CSS hides inactive panels. See mounting caveats above. |
All parts | className / style | string / CSSProperties | Not set | Merged scoped class and forwarded inline style on the actual part. Preserve focus indicators and inactive-panel hiding. |
All parts | asChild | boolean | false | Radix Slot composition: one element that accepts the ref and props. Preserve semantics and native disabled behavior; prefer the default elements. |
All parts | ref | React.Ref<HTMLDivElement> / React.Ref<HTMLButtonElement> | Not set | Tabs, TabsList and TabsContent forward div refs; TabsTrigger forwards the actual button ref. asChild changes the runtime element, not the declared ref type. |
DOM props and refs
HTML attributes, aria-*, data-*, styles and events pass through to each part. Radix composes trigger focus, key and pointer handlers with its behavior; preventDefault can suppress that behavior. Trigger defaults to type=button, so selecting tabs does not submit a form. Default elements are div, div, button and div respectively. Do not nest interactive controls inside triggers. TabsContent may override tabIndex when its content provides a suitable focus target.
Playground defaults
Reset restores the controlled overview value, Overview label, horizontal orientation, automatic activation and disabled Access tab. The playground controls are documentation UI, not additional Tabs props. Copy reflects the current selected view and configuration.