# SwitchGroup

A native form group for related on/off preferences.

Connect Flood once using [the installation guide](https://flood.md/docs/installation). Then import the components you use; no per-component add command is needed.

## Example

```tsx
"use client";

import { FloodRoot, SwitchGroup, Switch } from "@flood-md/react";
import "@flood-md/react/styles.css";

export function Example() {
  return (
    <FloodRoot>
      <SwitchGroup legend="Notifications">
        <Switch layout="row" label="New assignments" name="assignmentAlerts" defaultChecked />
        <Switch layout="row" label="Weekly summary" name="weeklyDigest" />
      </SwitchGroup>
    </FloodRoot>
  );
}
```

## Design notes

- Compose row switches inside one native fieldset. Each switch has its own state, name and optional description. The host owns persistence and when changes are saved.
- Set disabled on the whole group when it is unavailable. A child Switch can be readOnly when only its value is locked and the rest of the group remains editable.
- Choose compact or comfortable density. Dividers default to off. Use SettingGroup for a mix of switches, values and independent actions.

## API reference

| Prop | Values | Default |
| --- | --- | --- |
| `legend` | `ReactNode` | `Required` |
| `legendSize · 0.2.10` | `"label" \| "section"` | `—` |
| `hideLabel · 0.2.3` | `boolean` | `—` |
| `hint` | `ReactNode` | `—` |
| `error` | `ReactNode` | `—` |
| `message` | `ReactNode` | `—` |
| `status` | `"error" \| "warning" \| "success" \| "info"` | `—` |
| `density` | `"compact" \| "comfortable"` | `"comfortable"` |
| `dividers` | `boolean` | `false` |
| `Native HTML props` | `Omit<FieldsetHTMLAttributes<HTMLFieldSetElement>, "layout">` | `Forwarded` |
