Switch¶
Switch turns a setting on or off. The handle stretches as it moves. The track can show I and O marks.
Usage¶
Call Components.Switch with a scope and a table of properties:
C.Switch(scope, {
Label = "Notifications",
Checked = true,
OnChanged = function(on)
print("Notifications", on)
end,
})
Properties¶
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
Theme |
ThemeRef |
The contextual theme | Theme to use for this component instead of the one from Theme.Provide. |
|
LayoutOrder |
UsedAs<number> |
0 |
Position in a parent UIListLayout or UIGridLayout. |
|
Checked |
UsedAs<boolean> |
false |
The value. A plain value is only the starting value. A Value stays in step with the control: the user's changes set it, and setting it changes the control. |
|
Label |
UsedAs<string> |
- | Text next to the switch. | |
Disabled |
UsedAs<boolean> |
false |
Stops the switch reacting to input. The component reads this once, when it creates the switch. | |
Icons |
boolean |
theme.Controls.SwitchIcons |
Show the I and O marks on the track. Overrides theme.Controls.SwitchIcons. |
|
Id |
string |
- | Key that identifies this component when state is kept across rebuilds. See Persist. |
Callbacks¶
| Name | Description |
|---|---|
OnChanged: (boolean) -> () |
Runs with the new value when the user turns the switch on or off. |