This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 54).
A SwiftUI Switch component for toggle controls.
iOS
tvOS
A switch component that provides toggle functionality with different visual styles.
Installation
Terminal
-
npx expo install @expo/ui
If 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 { Host, Switch } from '@expo/ui/swift-ui'; <Host matchContents> <Switch checked={checked} onValueChange={checked => { setChecked(checked); }} color="#ff0000" label="Play music" variant="switch" /> </Host>
See Official SwiftUI documentation for more information.
Checkbox
import { Host, Switch } from '@expo/ui/swift-ui'; <Host matchContents> <Switch checked={checked} onValueChange={checked => { setChecked(checked); }} label="Play music" variant="checkbox" /> </Host>
See Official SwiftUI documentation for more information.
API
Component
Type: React.Element<SwitchProps>
Displays a native switch component.