Skip to content

Switch

The Switch provides a modern, mobile-friendly toggle for on/off states (like iOS switches).

PropertyTypeRequiredDescription
type"switch"YesIdentifies the field
labelstringYesShown next to the switch
schemaz.ZodTypeYesBoolean validation
Enable notifications toggle
basic-switch.tsx
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"],
},
},
});
  • Supports Space and Enter keys.
  • ARIA role="switch" is applied automatically.