---
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/"
---

# Segmented control

One choice of two to five short options that applies at once — a view or a mode — drawn as touching segments in one framed row, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `SegmentedControl`.

## When to use

- One choice of two to five short options that applies at once — a view or a mode — drawn as touching segments in one framed row.
- Use SegmentedControl for one of two to five short options that applies at once — a view or a mode; give it a label; it fills its column, `fit` in a header or a toolbar. For panels under a row of tabs use Tabs; for a row of filter pills, ToggleGroup; for a choice with descriptions, RadioGroup; for more options or long words, Select; for on and off, Switch. A status filter with counts: a `count` on each option, and a `countLabel` for a screen reader.
- Also called: segmented button.

## 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 Segmented control on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-segmented-control.json --yes
```

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

## Usage

```tsx
import { SegmentedControlIcon } from '@/components/ui/goop/segmented-control';

import { useState } from 'react';
import { SegmentedControl, SegmentedControlItem } from '@/components/ui/goop/segmented-control';

function BookingsHeader() {
  const [view, setView] = useState('week');
  return (
    <header className="flex items-center justify-between gap-2">
      <h1 className="text-lg font-semibold">Bookings</h1>
      <SegmentedControl aria-label="View" fit value={view} onValueChange={setView}>
        <SegmentedControlItem value="day">Day</SegmentedControlItem>
        <SegmentedControlItem value="week">Week</SegmentedControlItem>
        <SegmentedControlItem value="month" count={4}>
          Month
        </SegmentedControlItem>
      </SegmentedControl>
    </header>
  );
}
```

- Fits: schedule (its recipe).
- Also known as: SegmentedButton, ContentSwitcher, ViewSwitcher, ButtonToggle, PillSwitch.
- height, width, padding, gap, corner, border, background, text, motion: add no class for these.

## API reference

### Options

- `value?: string` — The chosen option's value, for a control its caller holds (with `onValueChange`).
- `defaultValue?: string` — The option chosen at first render; left out (and no `value`), the first option.
- `onValueChange?: (value: string) => void` — Called with the option's value whenever a person chooses one.
- `name?: string` — The native radios' name, sent with the form; a name of its own when left out, so two controls never share one.
- `size?: 'sm' | 'md' | 'lg' = 'md'` — The pill's outer height: `sm` 24 px, `md` 28 px, `lg` 32 px — the control it sits beside.
- `fit?: boolean = false` — As wide as its segments (a header's or a toolbar's control); left out, it fills its column in equal segments.
- `disabled?: boolean = false` — Every option off: the pill dimmed once, no option takes the focus, a press or a key.

- State: value (value / defaultValue / onValueChange); drawn by data-state=unchecked

### Parts

- `SegmentedControlItem` — One option of a SegmentedControl; its props: segmented-control--item.md
- `SegmentedControlIcon` — A segment's pack glyph in its words' ink, 6 px before them, 14 px (16 px at `lg`); decorative (the words or `aria-label` name it); icon: IconName — The pack's icon name

- data-slot values (to select a part by): segmented-control, segmented-control-count, segmented-control-icon, segmented-control-item, segmented-control-label, segmented-control-radio

### SegmentedControlItem

One option of a SegmentedControl.

```tsx
import { SegmentedControlItem } from '@/components/ui/goop/segmented-control';
```

### Options

- value: string — The value the control reports, and sends with the form, when this option is chosen.
- disabled?: boolean — This option off: dimmed, skipped by the arrows, no press chooses it.
- aria-label?: string — The option's name when it holds only a glyph (`SegmentedControlIcon`): required then.
- count?: number — How many the option holds ("Open 5"), drawn after its words as a quiet number; 0 is drawn (an empty status says so), and an option with no `count` draws none.
- countLabel?: (count: number) => string — The words a screen reader hears for the count after the option's name (`(n) => \`${n} open\``); the number by default.

## Keyboard

- Tab: move to the chosen option, then out of the group
- ArrowRight / ArrowDown: choose the next option, wrapping, skipping a disabled one
- ArrowLeft / ArrowUp: choose the previous option, wrapping, skipping a disabled one
- Space: choose the focused option
- Home / End: choose the first or the last option, skipping a disabled one

## Accessibility

- The native element answers the keyboard.
- hover, active: the browser's own (:hover, :active): write nothing
- checked: the attribute data-state=unchecked
- disabled: the prop disabled
- invalid: the attribute aria-invalid

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

- [Rating](/themes/meadow/components/rating): A row of stars to give a score, or to show an average with halves, for reviews, testimonials and feedback.
- [Color picker](/themes/meadow/components/color-picker): A painted area and channel sliders that choose one colour.
- [File upload](/themes/meadow/components/file-upload): A drop zone or a button to choose files, for attachments, an import or a photo, with a list of the chosen files.
- [Calendar](/themes/meadow/components/calendar): A month always in view, to choose a date or a range of dates.
