ObjectUIObjectUI

Switch

Toggle switch for binary options

Examples

Basic Switch

Multiple Switches

Schema

interface SwitchSchema {
  type: 'switch';
  name?: string;
  label?: string;
  defaultChecked?: boolean;
  disabled?: boolean | string | { dialect?: string; source: string };   // boolean, predicate expression, or CEL envelope
  wrapperClass?: string;
}

wrapperClass is now typed. The renderer has read it all along — it lands on the wrapper element around the switch and its label — but it went undeclared until objectui#7722, surviving on what was then BaseSchema's index signature (objectui#8347 removed it) and the zod mirror's .passthrough(). Declared as string on both faces, a non-string wrapperClass that used to parse green is now refused by name — on SwitchSchema and through safeValidateSchema alike. Pass the Tailwind class string; a number or an object gets a parse error where it used to get silence.

On this page