Installation
$ pnpm dlx shadcn@latest add @synccn/tabsFirst 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
stringControlled active tab.
- defaultValue
stringInitial tab when uncontrolled.
- onValueChange
(value: string) => voidCalled with the new tab.
- variant
"pill" | "underline"Default
"pill"Tab list style.
- className
stringExtra classes for the root element.
- children
React.ReactNodeContent to render.
TabsList
Tab list with a sliding indicator that follows the active trigger.
- className
stringExtra classes for the root element.
- children
React.ReactNodeContent to render.
TabsTrigger
- valuerequired
stringTab this trigger activates.
- disabled
booleanPrevents selection.
- className
stringExtra classes for the root element.
- children
React.ReactNodeContent to render.
TabsContent
- valuerequired
stringTab this panel belongs to.
- className
stringExtra classes for the root element.
- children
React.ReactNodeContent to render.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
npm packages
- clsx for cn()
- tailwind-merge for cn()
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