UIViews
Toggle
Switch a boolean value on or off.
A controlled switch. Pass the current isOn value and update it from onChange. children is the label.
import { Toggle, useState } from "onescript/views"
function WifiToggle() {
const [enabled, setEnabled] = useState(true)
return (
<Toggle
isOn={enabled}
onChange={setEnabled}
>
Wi-Fi
</Toggle>
)
}| Prop | Type | Description |
|---|---|---|
isOn | boolean | Current value. |
onChange | (isOn: boolean) => void | Runs when the user flips the switch. |
children | ViewChild | The label. |
Use toggleStyle to show it as a button and labelsHidden to hide the label. Also accepts Modifiers. It is only available in App and Action view sessions; widgets reject it with an unsupported view type error.
How is this guide?
Last updated on