---
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 list's filters or a view switch, 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 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.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-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, 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

### Parts

- `ToggleGroupItem` — One pill of the row; its props: toggle-group--item.md
- `ToggleGroupIcon` — A 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

- ArrowLeft / ArrowRight: move focus
- Home: move focus
- End: move focus
- Space: toggle
- Enter: 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
- selected: the attribute data-state=active
- pressed: the attribute data-state=off
- 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/meadow/components/link): A text link to another page or place.
- [Copy button](/themes/meadow/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/meadow/components/menu-button): The button a menu opens from, shown as words, a workspace's tile or an icon.
- [Color mode toggle](/themes/meadow/components/color-mode-toggle): The app's light and dark mode switch.
