VisorVisor
ComponentsNavigation

Tabs

Switch between content panels with default and line style variants. Built on Radix UI.

Default

Pill-style tabs with a background indicator.

Overview content here.

Line Variant

Underline-style tabs with a bottom border indicator.

Account settings.

Keyed Variant

A row of compact tabs that wraps onto as many lines as it needs. One highlight (a 1px key-colour edge over a 10% key fill) slides to the active tab in both directions, so it crosses a wrapped line too. It re-measures on resize, on font load and when tabs are added, removed or reordered; with prefers-reduced-motion it jumps. An icon placed before the label sits at 16px and takes the key colour when its tab is active. Extra children after the label (a small tag, say) render inside the trigger. size="compact" narrows the side padding from 12px to 10px. Theme it with --tabs-keyed-key, --tabs-keyed-fill, --tabs-keyed-ink and --tabs-keyed-radius.

DJ details.

Disabled Tab

Individual tabs can be disabled.

Active tab content.

Installation

npx visor add tabs

This copies two files into your project:

  • components/ui/tabs/tabs.tsx — the component
  • components/ui/tabs/tabs.module.css — the styles

Usage

import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs/tabs';

<Tabs defaultValue="overview">
  <TabsList variant="default">
    <TabsTrigger value="overview">Overview</TabsTrigger>
    <TabsTrigger value="settings">Settings</TabsTrigger>
  </TabsList>
  <TabsContent value="overview">Overview content.</TabsContent>
  <TabsContent value="settings">Settings content.</TabsContent>
</Tabs>

API Reference

TabsProps

No props data available for “tabs”.

Sub-components

ComponentElementPurpose
Tabs<div> (Radix Root)Root container. Requires defaultValue or controlled value.
TabsList<div>Horizontal container for tab triggers. Accepts variant (default, line, keyed) and, for keyed, size (default, compact).
TabsTrigger<button>Clickable tab button tied to content via matching value prop.
TabsContent<div>Content panel that displays when its matching trigger is active.

Accessibility

  • Built on @radix-ui/react-tabs with full WAI-ARIA tab semantics.
  • TabsList has role="tablist"; triggers have role="tab" with aria-selected.
  • Content panels have role="tabpanel" linked to their trigger via aria-labelledby.
  • ArrowLeft / ArrowRight navigate between triggers; Enter or Space activates.
  • Disabled triggers receive aria-disabled="true" and are skipped in keyboard navigation.

Label Centering

The label is optically centred in any font: its line box is trimmed to the capital-height band, so capitals (not the font's ascent and descent) sit on the box centre, with the box size unchanged. Firefox keeps the previous rendering. Shared spec: docs/label-centering.md.