Skip to content
synccn

Tabs

Pill or underline tabs with a sliding indicator and arrow keys.

Installation

$ pnpm dlx shadcn@latest add @synccn/tabs

First time in this project? Connect synccn with one command.

Usage

import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";<Tabs defaultValue="a">  <TabsList><TabsTrigger value="a">A</TabsTrigger></TabsList>  <TabsContent value="a">…</TabsContent></Tabs>

API reference

Generated from the component's TypeScript types, so it always matches the code.

Tabs

  • value
    string

    Controlled active tab.

  • defaultValue
    string

    Initial tab when uncontrolled.

  • onValueChange
    (value: string) => void

    Called with the new tab.

  • variant
    "pill" | "underline"

    Default "pill"

    Tab list style.

  • className
    string

    Extra classes for the root element.

  • children
    React.ReactNode

    Content to render.

TabsList

Tab list with a sliding indicator that follows the active trigger.

  • className
    string

    Extra classes for the root element.

  • children
    React.ReactNode

    Content to render.

TabsTrigger

  • valuerequired
    string

    Tab this trigger activates.

  • disabled
    boolean

    Prevents selection.

  • className
    string

    Extra classes for the root element.

  • children
    React.ReactNode

    Content to render.

TabsContent

  • valuerequired
    string

    Tab this panel belongs to.

  • className
    string

    Extra classes for the root element.

  • children
    React.ReactNode

    Content to render.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/utilscn (merges class names)
  • lib/hooksuseControllable (works controlled or uncontrolled)

npm packages

Keyboard

  • ←or→Move to the previous or next tab and show it
  • HomeorEndJump to the first or last tab

Accessibility

  • Uses tablist, tab and tabpanel roles, with aria-selected and aria-controls wired up.
  • Disabled tabs are skipped by the arrow keys.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: tab, tablist, tabpanel
  • ARIA attributes: aria-controls, aria-labelledby, aria-selected
  • Keys handled: ArrowLeft, ArrowRight, Home, End
  • Shows a visible focus ring for keyboard users