MenuChevron Down
Switch - Docs - Artefact

Switch

Forms
Smart auto-detect

Introduction

A control that allows the user to toggle between checked and unchecked states.

Usage

import { Switch } from "../components/ui";

export default function MyPage() {
  return (
    <Switch
      defaultChecked={true}
      onCheckedChange={(details) => console.log(details.checked)}
      interactive
    >
      Enable Notifications
    </Switch>
  );
}

CMS Page Builder

This component is available as a switch block in the Page Builder (content/pages/*.json):

{
  "type": "switch",
  "label": "Dark Mode",
  "checked": true,
  "colorPalette": "blue"
}

Props

PropTypeDescription
childrenanyLabel content to be rendered next to the switch.
classstringCustom CSS classes.
checkedbooleanWhether the switch is checked (controlled).
defaultCheckedbooleanThe initial checked state (uncontrolled).
disabledbooleanWhether the switch is disabled.
onCheckedChange(details: { checked: boolean }) => voidCallback triggered when the checked state changes.

| size | `"sm" \ | "md" \ | "lg"` | The size of the switch. |

| interactive | boolean | Forces hydration as an island. |