Switch Field
Toggle switch for boolean values.
Switch Field
The switch field renders a toggle switch for boolean values.
Schema Properties
Prop
Type
UI Options
Same as Text Field.
Basic Usage
const schema = defineSchema({
fields: [
{
type: "switch",
name: "notifications",
label: "Enable Notifications",
defaultValue: true,
},
],
});Examples
Feature Toggle
{
type: "switch",
name: "darkMode",
label: "Dark Mode",
description: "Switch between light and dark themes",
}Required Switch
{
type: "switch",
name: "consent",
label: "I consent to data processing",
required: true,
}Disabled Switch
{
type: "switch",
name: "premium",
label: "Premium Features",
disabled: true,
description: "Upgrade to unlock",
}Auto-Derived Validators
| Property | Validator |
|---|---|
required: true | required |