# ToggleGroup

A single-select group of options with radiogroup semantics.

## Options

Each option is a radio button; a disabled option stays in the row and cannot be chosen.

## Custom items

The `item` snippet receives `option`, spreadable `props` (role, aria state, click handling) and `selected`: any element can become a group member.

## Examples

```svelte
<script lang="ts">
  import Card from '@qualia-studios/design-ui/components/Card.svelte';
  import ToggleGroup from '@qualia-studios/design-ui/components/ToggleGroup.svelte';

  const options = [
    { value: 'act', label: 'ACT' },
    { value: 'pi0', label: 'Pi0' },
    { value: 'pi05', label: 'Pi0.5', disabled: true },
  ];
  let value = $state<string | undefined>('act');
  let cardValue = $state<string | undefined>();
</script>
```

### Example 1: A bound group

Pi0.5 is a disabled option.

```svelte
<ToggleGroup bind:value {options} />
<span>Selected: <code>{value ?? 'none'}</code></span>
```

### Example 2: Cards as options, from the item snippet

```svelte
<ToggleGroup bind:value={cardValue} {options} class="cards">
  {#snippet item({ option, props, selected })}
    <Card {...props} class={selected ? 'selected' : ''}>
      <strong>{option.label}</strong>
    </Card>
  {/snippet}
</ToggleGroup>
```

---

From the Qualia design guide: https://q-core-3b2732.gitlab.io/components/togglegroup. Every page as markdown: https://q-core-3b2732.gitlab.io/llms.txt
