npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-toggle-group.json --yesToggle group
ProA 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.
What an agent sees
- ToggleGroupItemOne toggle of the row
- ToggleGroupIconA toggle's glyph, decorative (the toggle carries the name)
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>
</>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);
fitin 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.
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-toggle-group.json --yesAdd the Goop Toggle group to this project. The install steps are at https://goop.so/docs/install.mdUsage
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
| Part | What it is |
|---|---|
| ToggleGroupItem | One toggle of the row; its props: toggle-group--item.md |
| ToggleGroupIcon | A 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).
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.
import { ToggleGroupItem } from '@/components/ui/goop/toggle-group';Options
- value: string — The toggle's value in the row's
value.
ToggleGroup: every option
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:
sm24 px (a chip or a small Select),md28 px (the default: a Button, aToolbarAction),lg32 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 (
''whenoptionallets 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
| Key | What it does |
|---|---|
| Tab | Enter the row on the toggle that is on (else the first), then leave it |
| ArrowLeft ArrowRight ArrowUp ArrowDown | Move the focus along the row, wrapping, without pressing (orientation="vertical": Up and Down only; "horizontal": Left and Right only) |
| Home End | Move the focus to the first or the last toggle |
| Space Enter | Press 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:
| State | Drawn by |
|---|---|
| pressed | the attribute data-state=on |
| disabled | the 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.