Skip to main content
Toggle switch component.
{
  "type": "object",
  "properties": {
    "type": {
      "const": "Switch",
      "default": "Switch",
      "type": "string"
    },
    "cssClass": {
      "type": [
        "string",
        "null"
      ],
      "default": null,
      "description": "CSS/Tailwind classes for styling"
    },
    "label": {
      "type": [
        "string",
        "null"
      ],
      "default": null,
      "description": "Label text"
    },
    "checked": {
      "default": false,
      "description": "Whether switch is on",
      "type": "boolean"
    },
    "size": {
      "default": "default",
      "description": "Switch size (sm, default)",
      "enum": [
        "sm",
        "default"
      ],
      "type": "string"
    },
    "name": {
      "type": [
        "string",
        "null"
      ],
      "default": null,
      "description": "Form field name"
    },
    "disabled": {
      "default": false,
      "description": "Whether switch is disabled",
      "type": "boolean"
    },
    "required": {
      "default": false,
      "description": "Whether switch is required",
      "type": "boolean"
    },
    "onChange": {
      "$ref": "Action",
      "description": "Action(s) to execute when toggled",
      "default": null
    }
  },
  "required": [
    "type"
  ]
}