Skip to content

Components

SwitchGroup

Notifications

Component reference

Properties

Use SwitchGroup

A native form group for related on/off preferences.

Example import style
switch-group.tsxTSX
"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

PropValuesDefault
legendReactNodeRequired
legendSize · 0.2.10"label" | "section"—
hideLabel · 0.2.3boolean—
hintReactNode—
errorReactNode—
messageReactNode—
status"error" | "warning" | "success" | "info"—
density"compact" | "comfortable""comfortable"
dividersbooleanfalse
Native HTML propsOmit<FieldsetHTMLAttributes<HTMLFieldSetElement>, "layout">Forwarded
View TypeScript source