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

Toggle group

Pro

A row of toggle buttons that act together, one or several pressed, such as a view switch or text formatting, 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 view switch or text formatting.
  • Use ToggleGroup for a row of tool-like switches that apply at once — one on (a view) or several (filters); fit in a top bar or toolbar, filling in a card; name glyph-only items. Not for one toggle alone (ToggleButton), a choice of named options in a form (SegmentedControl or RadioGroup), 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>/trail-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, ToggleGroupItem, ToggleGroupIcon } from '@/components/ui/goop/toggle-group';

<>
  <ToggleGroup fit aria-label="Layout" defaultValue="list">
    <ToggleGroupItem value="list" aria-label="List">
      <ToggleGroupIcon icon="list-search" />
    </ToggleGroupItem>
    <ToggleGroupItem value="board" aria-label="Board">
      <ToggleGroupIcon icon="columns-3" />
    </ToggleGroupItem>
    <ToggleGroupItem value="grid" aria-label="Grid">
      <ToggleGroupIcon icon="grid-dots" />
    </ToggleGroupItem>
  </ToggleGroup>
  <ToggleGroup type="multiple" aria-label="Show" defaultValue={['mine']}>
    <ToggleGroupItem value="mine">Mine</ToggleGroupItem>
    <ToggleGroupItem value="starred">Starred</ToggleGroupItem>
    <ToggleGroupItem value="archived">Archived</ToggleGroupItem>
  </ToggleGroup>
  <ToggleGroup fit variant="outline" size="lg" aria-label="Range" defaultValue="week">
    <ToggleGroupItem value="day">Day</ToggleGroupItem>
    <ToggleGroupItem value="week">Week</ToggleGroupItem>
    <ToggleGroupItem value="month">Month</ToggleGroupItem>
  </ToggleGroup>
  <ToggleGroup orientation="vertical" aria-label="Sort by" defaultValue="due">
    <ToggleGroupItem value="due">Due date</ToggleGroupItem>
    <ToggleGroupItem value="priority">Priority</ToggleGroupItem>
  </ToggleGroup>
</>
  • Fits: list, record: toolbar.
  • Also known as: ToggleButtonGroup.
  • height, width, padding, gap, corner, border, background, shadow, 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=on
Parts
PartWhat it is
ToggleGroupItemOne toggle of the row; its props: toggle-group--item.md
ToggleGroupIconA toggle's glyph, decorative (the toggle carries the name); its props: toggle-group--icon.md
  • data-slot values (to select a part by): toggle-group, toggle-group-icon, toggle-group-item, toggle-group-label

ToggleGroupIcon

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

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

Options

  • icon: IconName — A pack icon name (an outline icon, or a filled one).

ToggleGroupItem

One toggle of the row.

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

Options

  • value: string — The toggle's value in the row's value.

ToggleGroup: every option

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

Options

  • disabled?: boolean — Dims every toggle once and takes them all out of the keyboard's way.
  • fit?: boolean = false — As wide as its toggles, at its container's start: for a top bar, a toolbar or a page header (the common place for a row of glyphs).
  • size?: 'sm' | 'md' | 'lg' — The toggles' height, matched to the control beside them: sm 24 px (a chip or a small Select), md 28 px (the default: a Button, a ToolbarAction), lg 32 px with 13 px words and a 16 px glyph (a TextInput, a large Button).
  • variant?: 'soft' | 'outline' — soft (the default): separate toggles 2 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 ("Layout", "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 toggle on at a time, a choice such as a view. Or: multiple: any number of toggles on, each its own switch (filters, formatting).
  • value?: string | string[] — The value of the toggle that is on, held by the caller. Or: The values of the toggles that are on, held by the caller.
  • defaultValue?: string | string[] — The value of the toggle on at first, when the row holds its own. Or: The values of the toggles on at first, when the row holds its own.
  • onValueChange?: ((value: string) => void) | ((value: string[]) => void) — Called with the value of the toggle turned on ('' when optional lets the last one turn off). Or: Called with the values of the toggles on after a press.
  • optional?: boolean — The value may be none, as Select's optional: pressing the toggle that is on turns it off, leaving none on; left out, it stays on.
  • State: value (value / defaultValue / onValueChange); drawn by data-state=on

Keyboard

KeyWhat it does
TabEnter the row on the toggle that is on (else the first), then leave it
ArrowLeft ArrowRight ArrowUp ArrowDownMove the focus along the row, wrapping, without pressing (orientation="vertical": Up and Down only; "horizontal": Left and Right only)
Home EndMove the focus to the first or the last toggle
Space EnterPress the focused toggle

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
pressedthe attribute data-state=on
disabledthe prop disabled

Motion

  • The part sets its own motion: add no transition or animation of your own.
  • How the theme moves, and how to move your own parts the same way: Motion.

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