npx shadcn@4.23.1 add @goop/trail-tabsTabs
FreeA row of tabs that switch between panels of content in one place, such as a record's overview and activity, for React and Tailwind CSS. Free, MIT.
What an agent sees
- TabsListThe row of tabs
- TabsTriggerOne tab in the TabsList
- TabsActionA trailing control of the row (a new view, a view's options)
- TabsContentThe panel a tab shows
import { Tabs, TabsList, TabsTrigger, TabsAction, TabsContent } from '@/components/ui/goop/tabs';
<Tabs defaultValue="all">
<TabsList>
<TabsTrigger value="all" count={12} countLabel={(n) => `${n} open`}>
All
</TabsTrigger>
<TabsTrigger value="mine" count={3} countLabel={(n) => `${n} open`}>
Mine
</TabsTrigger>
</TabsList>
<TabsContent value="all">…</TabsContent>
</Tabs>Switch views with a click or the arrow keys (Home and End too): the indicator moves and the panel changes. Change the row’s variant, or leave the panels out. The tasks are words of our own.
When to use
- A row of tabs that switch between panels of content in one place, such as a record's overview and activity.
- Also called: tab bar.
Installation
Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Tabs on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.
npx shadcn@4.23.1 add @goop/trail-tabsAdd the Goop Tabs to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { Tabs, TabsList, TabsTrigger, TabsAction, TabsContent } from '@/components/ui/goop/tabs';
<Tabs defaultValue="all">
<TabsList>
<TabsTrigger value="all" count={12} countLabel={(n) => `${n} open`}>
All
</TabsTrigger>
<TabsTrigger value="mine" count={3} countLabel={(n) => `${n} open`}>
Mine
</TabsTrigger>
</TabsList>
<TabsContent value="all">…</TabsContent>
</Tabs>- Fits: record (its recipe).
- Queue tabs with counts above a list: give each
TabsTriggeritscountand acountLabelfor a screen reader (count={12} countLabel={(n) => \${n} open\}reads "Orders, 12 open"); a zero is drawn. - height, width, padding, gap, corner, border, background, shadow, text, motion: add no class for these.
API reference
| Option | Type | What it does |
|---|---|---|
| value? | string | |
| defaultValue? | string | |
| onValueChange? | (value: string) => void |
- State: value (value / defaultValue / onValueChange); drawn by data-state=open
| Part | What it is |
|---|---|
| TabsList | The row of tabs; variant: default (default), ghost, segmented, outline; action?: ReactNode — A control after the tabs, outside the tablist (a TabsAction); none by default; size?: 'sm' | 'md' = 'md' — The quiet and outlined rows' tab sides (the view pills and the segments keep theirs): md (the default) 12 px, sm 4 px for a tight row such as five presets in a 268 px layer; the tabs keep their height and touch size |
| TabsTrigger | One tab in the TabsList; its value names the TabsContent it shows; count?: number — How many the tab's view holds ("Orders 12"), drawn after its words as a quiet number; 0 is drawn (an empty queue says so), and a tab with no count draws none; countLabel?: (count: number) => string — The words a screen reader hears for the count after the tab's name ((n) => \${n} open\); the number by default; also takes value: string; disabled?: boolean |
| TabsAction | A trailing control of the row (a new view, a view's options); icon: IconName — A pack icon name (an outline or a filled one); also takes type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean; aria-label: string; tooltip?: string | false; tooltipKeys?: readonly string[]; loading?: boolean = false; loadingLabel?: string = 'Loading' |
| TabsContent | The panel a tab shows; also takes value: string |
- Class recipes (cva): tabsListVariants (TabsList)
- data-slot values (to select a part by): tabs, tabs-content, tabs-edge, tabs-hover, tabs-indicator, tabs-list, tabs-list-inner, tabs-trigger, tabs-trigger-count, tabs-trigger-label
Accessibility
- The behaviour layer under the part answers keys, focus and dismissal: never write your own.
- hover, active, focus-visible, focus-within: the browser's own (:hover, :active, :focus-visible, :focus-within): write nothing
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| selected | the attribute aria-selected |
| expanded | the attribute data-state=open |
| open | the attribute data-state=open |
| disabled | the prop disabled |
Motion
- The part sets its own motion: add no transition or animation of your own.
- How the theme moves, and how to move your own parts the same way: Motion.
Notes for AI
Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.