---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Toggle group

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.

Pro. Its export: `ToggleGroup`.

## Try it

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.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-toggle-group.json --yes
```

```text
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

### Parts

- `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).

```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

- 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
- 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.

## 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.

## Related

- [Link](/themes/trail/components/link): A text link to another page or place, in running text or on its own.
- [Copy button](/themes/trail/components/copy-button): A button that copies a value such as a link, a key or a command to the clipboard and says it was copied in place.
- [Menu button](/themes/trail/components/menu-button): The button a menu opens from, shown as words, a workspace's tile or an icon.
- [Color mode toggle](/themes/trail/components/color-mode-toggle): The app's switch between light and dark, as a button or a menu.
