This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 54).
A Jetpack Compose Switch component for toggle controls.
Android
A switch component that provides toggle functionality with different visual styles.
Installation
Terminal
- npx expo install @expo/uiIf you are installing this in an existing React Native app, make sure to install expo in your project.
Toggle switch
Note: also known as Toggle.
import { Switch } from '@expo/ui/jetpack-compose'; <Switch value={checked} onValueChange={checked => { setChecked(checked); }} color="#ff0000" label="Play music" variant="switch" />
See Official Jetpack Compose documentation for more information.
Checkbox
import { Switch } from '@expo/ui/jetpack-compose'; <Switch value={checked} onValueChange={checked => { setChecked(checked); }} label="Play music" color="#ff0000" variant="checkbox" />
See Official Jetpack Compose documentation for more information.
API
Component
Type: React.Element<SwitchProps>
Optional • Type:
stringLabel for the switch.
On Android, the label has an effect only when the
Switchis used inside aContextMenu.
Optional • Type:
(value: boolean) => voidCallback function that is called when the checked state changes.