Skip to content
v0.2.10

Switch

A labeled on/off setting with native checkbox form behavior.

Preview

Use Switch

Switch is a named export of @flood-md/react. Connect the package once, then import what you use.

First time here? Connect Flood
Example import style
switch.tsxTSX
"use client";

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

export function Example() {
  return (
    <FloodRoot>
      <Switch label="Email notifications" name="notifications" defaultChecked />
    </FloodRoot>
  );
}

Design notes

  • Switch uses a native checkbox with role="switch".
  • checked/defaultChecked, name/value, reset and disabled remain native. The component does not persist settings.
  • The control and visible label form one content-width unit with an 8px-at-16px-root internal gap. Use an explicit parent gap="4" (16px at that root) between units; the glyph keeps its token-defined size.

API reference

PropValuesDefault
labelReactNodeRequired
Native HTML propsOmit<InputHTMLAttributes<HTMLInputElement>, "type" | "size">Forwarded
View TypeScript source