Switch
Introduction
The switch component is a basic Moflow component that toggles between two states.
Configuration items
Category |
Configuration |
Example |
Description |
Content |
Default value |
Sets whether the switch is on by default. |
|
Label |
Label. For more information, see Common form properties. |
||
Enable text |
The text to display when the component is on. |
||
Turn off the text |
The text to display when the component is off. |
||
Interaction |
Hidden |
Hides the component. For more information, see Common properties. |
|
Keep layout when hidden |
Keeps the layout when the component is hidden. For more information, see Common properties. |
||
Loading |
Specifies whether to display the loading state. The component cannot be interacted with in the loading state. |
||
Disabled |
Specifies whether to disable the component. A disabled component cannot be interacted with. |
||
Style |
Margin |
The margin of the component. For more information, see Common properties. |
|
Layout |
The position of the switch button in the container. Options include left, center, and right. |
||
CSS Style |
Switch selected color |
The color of the switch when selected. |
|
Label font size |
The font size of the label text. |
Properties and methods
Name |
Type |
Example |
Description |
checked |
boolean |
|
The current selected state of the switch component. |
labelText |
string |
|
Read-only. The text content of the label for the current switch component. |
disabled |
boolean |
|
Read-only. Indicates whether the current switch component is disabled. |
loading |
boolean |
|
Read-only. Indicates whether the current switch component is in the loading state. |
setChecked |
func |
|
Sets the selected state of the current switch component. |
clearChecked |
func |
|
Clears the checked value of the component. |
Event callbacks
Configuration |
Description |
The callback that is triggered when the switch state changes. |