A text label displayed alongside the toggle switch.
The current state of the toggle.
Callback invoked when the user taps the toggle. Use this to update your state.
A switch control for toggling a boolean value on or off.
Toggle(props: {
label?: string;
isOn: boolean;
setIsOn: (value: boolean) => void;
}): Component;
const body = () => {
const [enabled, setEnabled] = useState(false)
return Toggle({ label: "Notifications", isOn: enabled, setIsOn: setEnabled })
}
const body = () => {
const [darkMode, setDarkMode] = useState(false)
return Toggle({ label: "Dark Mode", isOn: darkMode, setIsOn: setDarkMode })
.tint(Color("green"))
}
const body = () => {
const [wifi, setWifi] = useState(true)
const [bluetooth, setBluetooth] = useState(false)
return VStack({ spacing: 0 }, [
Toggle({ label: "Wi-Fi", isOn: wifi, setIsOn: setWifi })
.padding(16),
Divider(),
Toggle({ label: "Bluetooth", isOn: bluetooth, setIsOn: setBluetooth })
.padding(16),
])
}