Toggle
Turns a setting on or off.
When to use
- Use for a setting that takes effect immediately.
Examples
An on/off setting
Loading the example
<k:Toggle text="Show archived orders" change=".onChange"/>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast"], (Controller, Toast) => Controller.extend("sample.ToggleChange", {
onChange(event) {
Toast.show(event.getParameter("selected") ? "Archived orders shown" : "Archived orders hidden");
}
}));Control dispatch alerts
Loading the example
<k:Toggle text="Delivery alerts" selected="true" help="Notify me when a carrier checks in." change=".onChange"/>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast"], (Controller, Toast) => Controller.extend("sample.ToggleChange", {
onChange(event) {
Toast.show(event.getParameter("selected") ? "Delivery alerts enabled" : "Delivery alerts paused");
}
}));API
Properties
| Name | Type | Default | Description |
|---|---|---|---|
selected | boolean | false | Whether the switch is on |
text | string | Label text | |
help | string | Supporting text | |
enabled | boolean | true | Whether the switch can be used |
Events
| Name | Type | Description |
|---|---|---|
change | selected: boolean | The switch state changed |