---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Tabs

A row of tabs over the panels they show, one panel at a time, for React and Tailwind CSS. Free, MIT.

Free. Its export: `Tabs`.

## Try it

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 over the panels they show, one panel at a time.
- 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.

```sh
npx shadcn@4.23.1 add @goop/meadow-tabs
```

```text
Add the Goop Tabs to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

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

function SiteVisitTabs() {
  return (
    <Tabs defaultValue="overview">
      <TabsList aria-label="Site visit" action={<TabsAction icon="plus" aria-label="New view" />}>
        <TabsTrigger value="notes" count={21}>
          Field notes
        </TabsTrigger>
        <TabsTrigger value="overview">Overview</TabsTrigger>
        <TabsTrigger value="tasks" count={3} countLabel={(n) => `${n} open`}>
          Tasks
        </TabsTrigger>
        <TabsTrigger value="photos" disabled>
          Photos
        </TabsTrigger>
      </TabsList>
      <TabsContent value="notes" className="py-3 text-sm">
        Soil samples from the north field
      </TabsContent>
      <TabsContent value="overview" className="py-3 text-sm">
        Drainage looks sound; the culvert needs clearing.
      </TabsContent>
      <TabsContent value="tasks" className="py-3 text-sm">
        Book the survey crew for Friday
      </TabsContent>
    </Tabs>
  );
}
```

- height, width, padding, gap, corner, border, background, shadow, text, motion: add no class for these.

## API reference

### Options

- `value?: string` — The selected tab's value, held by the caller; with `onValueChange`.
- `defaultValue?: string` — The tab selected at first, when the tabs hold it.
- `onValueChange?: (value: string) => void` — Called with the value of the tab just selected.

- State: value (value / defaultValue / onValueChange)

### Parts

- `TabsList` — The row of tabs, a `tablist`; name it with `aria-label` where no heading names it; variant?: 'default' | 'ghost' | 'segmented' | 'outline' = 'default' — The row's look: the underlined row (the default), quiet pills, joined framed pills or raised pills; size?: 'sm' | 'md' = 'md' — The quiet and raised pills' sides: `md` (the default) 10 px, `sm` 4 px; the tabs keep their height; action?: ReactNode — A control after the tabs, outside the tablist (a `TabsAction`); none by default
- `TabsTrigger` — One tab in the TabsList; its value names the TabsContent it shows; value: string — The tab's name among its siblings: the `value` of the TabsContent it shows; disabled?: boolean — The tab cannot be selected, and the keyboard passes over it; count?: number — How many the tab's view holds ("Tasks 6"), drawn after its words as small grey figures; 0 is drawn (an empty view 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
- `TabsAction` — A trailing control of the row (a new view, a view's options), passed as the TabsList's `action`; icon: IconName — A pack icon name; 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, a `tabpanel` named by its tab; shown while its tab is selected, out of the page otherwise (`forceMount` keeps it in the page, hidden, for content that must keep its state); also takes value: string

- Class recipes (cva): tabsListVariants
- data-slot values (to select a part by): tabs, tabs-badge, tabs-content, tabs-indicator, tabs-label, tabs-list, tabs-row, tabs-trigger

## Keyboard

- ArrowLeft / ArrowRight: move selection
- Home: move selection
- End: move selection

## Accessibility

- The behaviour layer under the part answers keys, focus and dismissal: never write your own.
- hover, active, focus, focus-visible, focus-within: the browser's own (:hover, :active, :focus, :focus-visible, :focus-within): write nothing
- selected: the attribute aria-selected
- disabled: the prop disabled

## Motion

- The part sets its own motion: add no transition or animation of your own.

## 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.

## Related

- [Breadcrumb](/themes/meadow/components/breadcrumb): The row of links from the top of the app down to the current page, so a person can step back up a level.
- [Pagination](/themes/meadow/components/pagination): The row of steps to the page before and the page after, at the foot of a page that is one of a run (a settings section, a guide's chapter).
- [Accordion](/themes/meadow/components/accordion): Stacked sections that each open and close their own content.
- [Collapsible](/themes/meadow/components/collapsible): One trigger that shows and hides the content right below it, such as more options.
