Switch
The Switch provides a modern, mobile-friendly toggle for on/off states (like iOS switches).
Properties
Section titled “Properties”| Property | Type | Required | Description |
|---|---|---|---|
type | "switch" | Yes | Identifies the field |
label | string | Yes | Shown next to the switch |
schema | z.ZodType | Yes | Boolean validation |
Example
Section titled “Example”Enable notifications toggle
import { z } from "zod";import { createExampleForm } from "../createExampleForm";
export const BasicSwitch = createExampleForm({ formId: "basic-switch", fields: { notifications: { type: "switch", label: "Enable notifications", schema: z.boolean(), }, }, steps: { step1: { id: "step1", fields: ["notifications"], }, },});Accessibility
Section titled “Accessibility”- Supports Space and Enter keys.
- ARIA
role="switch"is applied automatically.