# ToggleGroup

Single/multiple pressed-button toolbar with roving arrow navigation.

[All components](https://rickylabs.github.io/netscript/design-system/components/) · [Theme builder](https://rickylabs.github.io/netscript/create/) · [Implementation source](https://github.com/rickylabs/netscript/blob/main/packages/fresh-ui/registry/components/ui/toggle-group.tsx)

## Live preview

[Open live toggle-group preview](https://rickylabs.github.io/netscript/assets/fresh-ui/preview/?component=toggle-group&theme=studio-utility)

## Install

```bash
netscript ui:add toggle-group
```

## Usage and examples

The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.

```tsx
import { useState } from 'preact/hooks';
import { ToggleGroup } from '@app/components/ui/toggle-group.tsx';

export function Example() {
  const [value, setValue] = useState('standard');
  const [open, setOpen] = useState(false);
  const [notice, report] = useState('');
  return (<><div><ToggleGroup label="Order view" items={[{value:"list",label:"List"},{value:"grid",label:"Grid"}]} /></div><p role="status">{notice}</p></>);
}
```

## Props

Generated from native `deno doc --json --private` over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.

| Owner | Prop | Type | Optional | Description |
| --- | --- | --- | --- | --- |
| `ToggleGroupProps` | `class` | `string` | Yes |  |
| `ToggleGroupProps` | `label` | `string` | No |  |
| `ToggleGroupProps` | `items` | `[object Object]` | No |  |
| `ToggleGroupProps` | `type` | `"single" \| "multiple"` | Yes |  |
| `ToggleGroupProps` | `variant` | `"default" \| "outline" \| "segmented"` | Yes |  |
| `ToggleGroupProps` | `orientation` | `"horizontal" \| "vertical"` | Yes |  |
| `ToggleGroupProps` | `size` | `"sm" \| "md"` | Yes |  |
| `ToggleGroupProps` | `value` | `[object Object]` | Yes |  |
| `ToggleGroupProps` | `defaultValue` | `[object Object]` | Yes |  |
| `ToggleGroupProps` | `onValueChange` | `(value: [object Object]) => void` | Yes |  |
| `ToggleGroupProps` | `disabled` | `boolean` | Yes |  |

```typescript
ToggleGroupProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "class">
```

## Keyboard

| Key | Action |
| --- | --- |
| `Arrow keys` | Move focus between toggles |
| `Home/End` | Focus first/last toggle |
| `Enter/Space` | Toggle focused item |

## Tokens

Semantic contract roles: `space/inline/gap`.

CSS custom properties referenced directly: `--ns-component-tabs-selected`, `--ns-control-gap`, `--ns-fg`, `--ns-muted`, `--ns-radius-control`, `--ns-space-1`, `--ns-space-1-5`, `--ns-studio-signal-marker`, `--ns-studio-tabs-gap`, `--ns-studio-tabs-pad`, `--ns-studio-tabs-radius`, `--ns-studio-tabs-sel-bg`, `--ns-studio-tabs-track`.

## Contract and compatibility

Accessibility pattern: [WAI-ARIA guidance](https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/)

- Native CSS pseudo-classes carry transient focus/hover; data-state also supports deliberate preview renders. Native button semantics preserve form behavior.

Design contract values marked planned are not implementation props. The props above describe what ships today.
