# Toggle Group · JGuang UI

> A set of two-state buttons that can be toggled on or off.

- Page: https://jiguang132.com/systems/jguang-ui/docs/components/radix/toggle-group
- Based on: shadcn/ui documentation (MIT) @ bc0705384b51252af26dcc65425b216bf5eb063c

> Example `toggle-group-demo`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/toggle-group


## Installation


  

**Command**


  

**Manual**


```text
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.
```


### Install the following dependencies:


```bash
npm install radix-ui
```


### Copy and paste the following code into your project.


[View complete source: components/ui/toggle-group.tsx](/r/jguang-ui/radix/toggle-group.json)


### Update the import paths to match your project setup.


## Usage

```tsx
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
```

```tsx
<ToggleGroup type="single">
  <ToggleGroupItem value="a">A</ToggleGroupItem>
  <ToggleGroupItem value="b">B</ToggleGroupItem>
  <ToggleGroupItem value="c">C</ToggleGroupItem>
</ToggleGroup>
```

## Composition

Use the following composition to build a `ToggleGroup`:

```text
ToggleGroup
├── ToggleGroupItem
└── ToggleGroupItem
```

## Outline

Use `variant="outline"` for an outline style.


> Example `toggle-group-outline`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/toggle-group


## Size

Use the `size` prop to change the size of the toggle group.


> Example `toggle-group-sizes`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/toggle-group


## Spacing

Use `spacing` to add spacing between toggle group items.


> Example `toggle-group-spacing`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/toggle-group


## Vertical

Use `orientation="vertical"` for vertical toggle groups.


> Example `toggle-group-vertical`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/toggle-group


## Disabled


> Example `toggle-group-disabled`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/toggle-group


## Custom

A custom toggle group example.


> Example `toggle-group-font-weight-selector`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/toggle-group


## RTL

To enable RTL support in JGuang UI, see the [RTL configuration guide](/systems/jguang-ui/docs/rtl).


> Example `toggle-group-rtl`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/toggle-group


## API Reference

See the [Radix Toggle Group](https://www.radix-ui.com/docs/primitives/components/toggle-group#api-reference) documentation.

## Changelog

### 2026-05-17 Default Spacing

Changed the default `spacing` from `0` to `2` so toggle groups render with space between items by default. Use `spacing={0}` for connected items.

---

Index of all JGuang resources: https://jiguang132.com/llms.txt
