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

Toggle group

Pro

A row of toggle buttons that act together, one or several pressed, such as a list's filters or a view switch, for React and Tailwind CSS. Part of Goop Pro.

Press a toggle, or Tab in and use the arrow keys (Up and Down when stacked) and Space; switch one on or several, what the toggles hold, the three sizes, the joined outline look, stacked, the last toggle off, long words, and disable it. Look puts the row alone, in a toolbar, filling a card, or at each size beside a Button. No tasks are shown or filtered: the line under it only says the state.

When to use

  • A row of toggle buttons that act together, one or several pressed, such as a list's filters or a view switch.
  • Use ToggleGroup for a row of filters or views that apply at once — one on (a list's filter) or several; fit over a list or in a toolbar, filling in a card; a count on each pill that filters a list; name glyph-only items. Not for one toggle alone (ToggleButton) or tabs that show panels (Tabs).

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 Toggle group 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-toggle-group.json --yes
PROMPT
Add the Goop Toggle group to this project. The install steps are at https://goop.so/docs/install.md

Usage

TSX
import { ToggleGroup, ToggleGroupIcon, ToggleGroupItem } from '@/components/ui/goop/toggle-group';

function NoteFilters({ onFilter }: { onFilter: (filter: string) => void }) {
  return (
    <div className="flex items-center gap-2">
      <ToggleGroup fit aria-label="Notes" defaultValue="all" onValueChange={onFilter}>
        <ToggleGroupItem value="all" count={24}>
          All
        </ToggleGroupItem>
        <ToggleGroupItem value="open" count={5}>
          Open
        </ToggleGroupItem>
        <ToggleGroupItem value="done" count={19}>
          Done
        </ToggleGroupItem>
      </ToggleGroup>
      <ToggleGroup fit aria-label="View" defaultValue="list">
        <ToggleGroupItem value="list" aria-label="List">
          <ToggleGroupIcon icon="text-align-justify" />
        </ToggleGroupItem>
        <ToggleGroupItem value="starred" aria-label="Starred">
          <ToggleGroupIcon icon="star" />
        </ToggleGroupItem>
      </ToggleGroup>
    </div>
  );
}
  • Fits: board, inbox, list (their recipes); list, record: toolbar.
  • Also known as: ToggleButtonGroup.
  • height, width, padding, gap, corner, border, background, text, motion: add no class for these.

API reference

  • Each option with its sentence: toggle-group--options.md
  • State: value (value / defaultValue / onValueChange); drawn by data-state=active, data-state=off
Parts
PartWhat it is
ToggleGroupItemOne pill of the row; its props: toggle-group--item.md
ToggleGroupIconA pill's glyph, decorative (the pill carries the name); its props: toggle-group--icon.md
  • data-slot values (to select a part by): toggle-group, toggle-group-badge, toggle-group-edge, toggle-group-icon, toggle-group-item, toggle-group-label, toggle-group-text, toggle-group-wrapper

ToggleGroupIcon

A pill's glyph, decorative (the pill carries the name).

TSX
import { ToggleGroupIcon } from '@/components/ui/goop/toggle-group';

Options

  • icon: IconName — A pack icon name.

ToggleGroupItem

One pill of the row.

TSX
import { ToggleGroupItem } from '@/components/ui/goop/toggle-group';

Options

  • value: string — The pill's value in the row's value.
  • count?: number — How many the pill's filter holds ("Open 4"), drawn after its words as small grey figures; 0 is drawn (an empty filter says so), and a pill with no count draws none.
  • countLabel?: (count: number) => string — The words a screen reader hears for the count after the pill's name ((n) => \${n} open\); the number by default.

ToggleGroup: every option

TSX
import { ToggleGroup } from '@/components/ui/goop/toggle-group';

Options

  • disabled?: boolean — Dims every pill once and takes them all out of the keyboard's way.
  • fit?: boolean = false — As wide as its pills, at its container's start: for a filter row over a list, a toolbar or a page header.
  • scroll?: boolean = false — One line that scrolls in its container, as wide as it is, its pills at their own width and its ends fading where more lie: a strip of lists over a column.
  • size?: 'sm' | 'md' | 'lg' — The pills' height, matched to the control beside them: sm 24 px with 12 px words, md 28 px (the default: a Button, a ToggleButton), lg 32 px with a 16 px glyph.
  • variant?: 'soft' | 'outline' — soft (the default): separate pills 4 px apart, bare until on.
  • orientation?: 'horizontal' | 'vertical' — horizontal (the default): a row, Left and Right moving along it (left out, Up and Down move too).
  • aria-label?: string — The row's name ("Lists", "Show"), which a screen reader says first; or name it by aria-labelledby.
  • aria-labelledby?: string — The id of the words that name the row, in place of aria-label.
  • type?: 'single' | 'multiple' — single (the default): one pill on at a time, a choice such as a list's filter or a view. Or: multiple: any number of pills on, each its own switch (filters that add up).
  • value?: string | string[] — The value of the pill that is on, held by the caller. Or: The values of the pills that are on, held by the caller.
  • defaultValue?: string | string[] — The value of the pill on at first, when the row holds its own. Or: The values of the pills on at first, when the row holds its own.
  • onValueChange?: ((value: string) => void) | ((value: string[]) => void) — Called with the value of the pill turned on ('' when optional lets the last one turn off). Or: Called with the values of the pills on after a press.
  • optional?: boolean — The value may be none: pressing the pill that is on turns it off, leaving none on; left out, it stays on.
  • State: value (value / defaultValue / onValueChange); drawn by data-state=active, data-state=off

Keyboard

KeyWhat it does
ArrowLeft ArrowRightMove focus
HomeMove focus
EndMove focus
SpaceToggle
EnterToggle

Accessibility

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

Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:

StateDrawn by
selectedthe attribute data-state=active
pressedthe attribute data-state=off
disabledthe 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.

goop.so/themes/meadow/components/toggle-group.md · the page as Markdown
Theme
Install with your agentnpx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-toggle-group.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.