Theme
Install with your agentnpx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-segmented-control.json --yes

Segmented control

Pro

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.

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.

Terminal
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-segmented-control.json --yes
PROMPT
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
OptionTypeWhat it does
value?stringThe chosen option's value, for a control its caller holds (with onValueChange).
defaultValue?stringThe option chosen at first render; left out (and no value), the first option.
onValueChange?(value: string) => voidCalled with the option's value whenever a person chooses one.
name?stringThe 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 = falseAs wide as its segments (a header's or a toolbar's control); left out, it fills its column in equal segments.
disabled?boolean = falseEvery 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
PartWhat it is
SegmentedControlItemOne option of a SegmentedControl; its props: segmented-control--item.md
SegmentedControlIconA 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

KeyWhat it does
TabMove to the chosen option, then out of the group
ArrowRight ArrowDownChoose the next option, wrapping, skipping a disabled one
ArrowLeft ArrowUpChoose the previous option, wrapping, skipping a disabled one
SpaceChoose the focused option
Home EndChoose 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:

StateDrawn by
checkedthe attribute data-state=unchecked
disabledthe prop disabled
invalidthe 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.

goop.so/themes/meadow/components/segmented-control.md · the page as Markdown
Theme
Install with your agentnpx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-segmented-control.json --yes

Where would you like to start?

Free · now

The Goop plugin

A design system for your AI coding agent, so screen ten matches screen one.

/plugin marketplace add goop-so/skillsthen /plugin install goop@goopCodex, Cursor, ChatGPT, the Claude app and more: Connect Goop
FreePro

The components

Every part live, with its props, its keys and what an agent sees. Whole page and app templates, working with sample data.