# ToggleGroup

Choose one or several options shown at once: filter pills with counts, or joined segments, as buttons or links.

- **Use it for**: Choosing one or several options shown at once: filter pills with counts, or joined segments (variant="segmented"), as buttons or URL links.
- **Not for**: Switching between panels of content. Try [Tabs](https://unseenui.com/components/tabs/), [Select](https://unseenui.com/components/select/).

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { ToggleGroup } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<ToggleGroup variant="pills" label="Topics" options={topics} value={topic} onValueChange={setTopic} />
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `allowEmpty` | `boolean` | Lets the selected chip be deselected again. |
| `disabled` | `boolean` |  |
| `label` (required) | `string` | Names the group for assistive technology. |
| `mode` | `"buttons" \| "links"` | Buttons use radio semantics with one tab stop. |
| `onValueChange` | `((value: string \| null) => void) \| undefined \| (value: readonly string[]) => void` | Required with buttons. |
| `options` (required) | `readonly ToggleGroupOption[]` | Immutable choices; replace the array when labels or counts change. |
| `size` | `"default" \| "sm"` |  |
| `type` | `"single" \| undefined \| "multiple"` |  |
| `value` (required) | `string \| null \| readonly string[]` |  |
| `variant` | `"segmented" \| "pills"` |  |

## Keyboard

Tab reaches the group once. Arrow keys, Home and End move between enabled options; in single mode they also select. Space or Enter toggles an option in multiple mode. In links mode every link is in the tab order.

## Works with

[Chip](https://unseenui.com/components/chip/), [CopyButton](https://unseenui.com/components/copy-button/), [AppearanceToggle](https://unseenui.com/components/appearance-toggle/), [Button](https://unseenui.com/components/button/), [IconButton](https://unseenui.com/components/icon-button/)

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