# Toggle Button Group

> Group of mutually exclusive (or multiple) toggle buttons.

Registry name: `toggle-button-group`. HTML docs: https://ui.anuragroy.dev/component/toggle-button-group.

## Install

```bash
npx shadcn@latest add https://ui.anuragroy.dev/r/toggle-button-group.json
```

If the website is down: `npx shadcn@latest add https://raw.githubusercontent.com/anurag-roy/ui.anuragroy.dev/main/public/r/toggle-button-group.json`.

Registry JSON: https://ui.anuragroy.dev/r/toggle-button-group.json (GitHub: https://raw.githubusercontent.com/anurag-roy/ui.anuragroy.dev/main/public/r/toggle-button-group.json).

## Import

Import paths follow the consumer `components.json` aliases. After a default install:

```tsx
import { ToggleButtonGroup } from "@/components/ui/toggle-button-group"
```

## Usage

```tsx
import { ToggleButton } from "@/components/ui/toggle-button"
import { ToggleButtonGroup } from "@/components/ui/toggle-button-group"

export function Example() {
  return (
    <ToggleButtonGroup defaultValue={["left"]}>
      <ToggleButton value="left">Left</ToggleButton>
      <ToggleButton value="center">Center</ToggleButton>
      <ToggleButton value="right">Right</ToggleButton>
    </ToggleButtonGroup>
  )
}
```

## API

### ToggleButtonGroup

Base UI ToggleGroup root. Child `ToggleButton`s need a `value`.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `defaultValue` | string[] | — | Uncontrolled selected values. |
| `value` | string[] | — | Controlled selected values. |

## See also

- [HTML page](https://ui.anuragroy.dev/component/toggle-button-group): Preview and the same docs in the site chrome.
- [Registry item](https://ui.anuragroy.dev/r/toggle-button-group.json): Source files and dependencies.
- [Catalog](https://ui.anuragroy.dev/component): All components.
- [llms.txt](https://ui.anuragroy.dev/llms.txt): Agent index for this library.
