---
title: "Toggle Group"
description: "A set of toggles that share one value, such as text alignment. One or many can be on, in a row, a column, or as picture tiles."
url: https://gelatinui.com/components/toggle-group
markdown_url: https://gelatinui.com/components/toggle-group.md
access: free
install: "npx shadcn@latest add @gelatin-ui/toggle-group"
registry_item: https://gelatinui.com/r/toggle-group.json
version: "2026-11-08"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Toggle Group

> A set of toggles that share one value, such as text alignment. One or many can be on, in a row, a column, or as picture tiles.

Page: https://gelatinui.com/components/toggle-group

## When to use it

Best for: A row of toggles that share one value: one choice or many.

- Use it for a value that takes one choice or many.
- Use `multiple` for many at once.
- Use `orientation="vertical"` for a column.

## When not to use it

- To switch between views or panels, use tabs.
- For one choice from a short list with no empty state, use a [Segmented Control](https://gelatinui.com/components/segmented-control.md).

## Notes for agents

- The value is always an array of the pressed values.
- Single mode can turn all items off. To keep one on, call `eventDetails.cancel()` in `onValueChange` when the new value is empty.
- Icon-only items need an `aria-label`.
- `spacing` is the gap: `2` (8px) is the default.
- `ToggleGroupTile` is a tile with a caption or a picture.

## Anatomy

```text
ToggleGroup
├─ ToggleGroupItem (0..n)
└─ ToggleGroupTile (0..n)
   ├─ ToggleGroupTileBox (0..n)
   └─ ToggleGroupTileCaption (0..n)
```

## API reference

### ToggleGroup

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `"default" \| "lg" \| "sm" \| "xs"` | "default" | Height 24, 28, 32, or 36px. |
| `rounded` | `"default" \| "full"` | "default" |  |
| `className` | `string` |  |  |
| `variant` | `"default" \| "outline"` | "outline" | The look of the items: `outline` (default) for a row of toggles, `default` for quiet rows with no border (a list of places or views in a panel, pressed on the accent fill). |
| `spacing` | `0.5 \| 1 \| 2 \| 3 \| 4` | 2 | The gap between the items: 0.5 to 4 is 2 to 16px. Default 2 (8px). |

Also takes every prop of Base UI `ToggleGroup`: https://base-ui.com/react/components/toggle-group

### ToggleGroupItem

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `size` | `"default" \| "lg" \| "sm" \| "xs"` |  | Height 24, 28, 32, or 36px. |
| `rounded` | `"default" \| "full"` |  |  |

Also takes every prop of Base UI `Toggle`: https://base-ui.com/react/components/toggle

### ToggleGroupTile

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `size` | `TileSize` |  | `sm` 56 × 40, `default` 72 × 48, or `lg` 88 × 56. Default: from the group `size`. |
| `media` | `boolean` | false | A square picture tile (`#/lib/tile` `media`): the box holds a sample `<img>` that fills it, and the 2px pressed edge draws over it. Default false. |

Also takes every prop of Base UI `Toggle`: https://base-ui.com/react/components/toggle

### ToggleGroupTileBox

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### ToggleGroupTileCaption

No props of its own: `className`, `children`, and every other prop go to the element it renders.

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| ToggleGroup | `toggle-group` |  |  | `hit-area` |
| ToggleGroupItem | `toggle-group-item` |  |  |  |
| ToggleGroupTile | `toggle-group-tile` |  |  |  |
| ToggleGroupTileBox | `toggle-group-tile-box` |  |  |  |
| ToggleGroupTileCaption | `toggle-group-tile-caption` |  |  |  |

## Usage

Put a `ToggleGroupItem` per choice.

```tsx title="range-picker.tsx"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";

export function RangePicker() {
  return (
    <ToggleGroup aria-label="Range" defaultValue={["week"]}>
      <ToggleGroupItem value="day">Day</ToggleGroupItem>
      <ToggleGroupItem value="week">Week</ToggleGroupItem>
      <ToggleGroupItem value="month">Month</ToggleGroupItem>
    </ToggleGroup>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/toggle-group
```

It adds 15 registry items: 12 files, 1884 lines, and the npm packages `@base-ui/react`, `clsx`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Toggle](https://gelatinui.com/components/toggle.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Toggle](https://gelatinui.com/components/toggle.md)
- [Segmented Control](https://gelatinui.com/components/segmented-control.md): Pick Segmented Control for one choice from a few attached options that always has a value.
- [Radio Group](https://gelatinui.com/components/radio-group.md)
- [Tabs](https://gelatinui.com/components/tabs.md): Pick Tabs to switch between views or panels of one thing.

## Keyboard

| Keys | Action |
| --- | --- |
| Tab | Moves focus to the group. It has one tab stop. |
| Left Arrow, Right Arrow, Up Arrow, Down Arrow | Moves the focus. It does not change the value. Right to left flips the sides. |
| Home, End | Goes to the first or the last item. |
| Enter, Space | Presses the focused item. |

## Accessibility

Give the group an `aria-label`.

Each item is a button with a pressed state.

`loopFocus` is on, so the arrow keys wrap.
