Skip to main content

Toggle

The Toggle component is a customizable switch control designed to be used in forms.

Schema

[
{
"name": "toggle-feature",
"meta": {
"displayName": "Enable Feature",
"description": "Toggle to enable or disable the feature.",
"displayType": "toggle",
"readOnly": false,
"value": false,
"validation": {
"disabled": false
}
}
},
{
"name": "toggle-feature-2",
"meta": {
"displayName": "Disabled Feature",
"description": "Soon Feature",
"displayType": "toggle",
"value": false,
"readOnly": false,
"validation": {
"disabled": true
}
}
}
]

Example

Toggle to enable or disable the feature.

Soon Feature

Form Data:
{}

Schema for a Required Switch

[
{
"name": "toggle-feature",
"form": {
"displayName": "Enable Feature",
"displayType": "toggle",
"description": "Toggle to enable or disable the feature.",
"value": false,
"validation": {
"required": true,
"disabled": false
}
}
}
]

Schema for a Disabled Switch

[
{
"name": "toggle-feature-disabled",
"meta": {
"displayName": "Enable Feature (Disabled)",
"displayType": "toggle",
"description": "This switch is disabled.",
"value": false,
"validation": {
"required": false,
"disabled": true
}
}
}
]

Schema for a Switch with Initial Value Set to True

[
{
"name": "toggle-feature-on",
"meta": {
"displayName": "Enable Feature (Initially On)",
"displayType": "toggle",
"description": "This switch is initially on.",
"value": true,
"validation": {
"required": false,
"disabled": false
}
}
}
]

Field Properties

Properties used by this field (inside form field in schema)

NameDescriptionType
nameThe unique identifier for the switch control instance.string
displayNameA string that sets the display name of the switch control.string
descriptionA string providing additional information or instructions about the switch control.string
valueThe initial value of the switch control.boolean
validationAn object for validation rules.object
requiredA boolean indicating if the switch control is required (within validation).boolean
readOnlyA readonly field is not editable and value cannot be changedboolean
disabledA boolean indicating if the switch control is disabled (within validation).boolean

Field Properties - Validation Details

The validation settings within the Textarea component are crucial for ensuring that user input meets specific requirements. Here’s a breakdown of the available validation properties:

PropertyDescription
requiredBoolean value that specifies whether entering data into the field is mandatory.
validateA function for custom validation logic, which can return a boolean or an error message.
requiredDetailContains info msgs about the required validation property