npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-segmented-control.json --yesSegmented control
ProOne 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.
What an agent sees
- SegmentedControlItemOne option of a SegmentedControl
- SegmentedControlIconA segment's pack glyph in its words' ink, 6 px before them, 14 px (16 px at
lg)
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>
);
}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,
fitin 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: acounton each option, and acountLabelfor 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.
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-segmented-control.json --yesAdd the Goop Segmented control to this project. The install steps are at https://goop.so/docs/install.mdUsage
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
| Option | Type | What it does |
|---|---|---|
| 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
| Part | What it is |
|---|---|
| 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.
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
countdraws 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
| Key | What it does |
|---|---|
| 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
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| 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.