Switch
A controlled component that renders a boolean input.
Switch
requires an onValueChange callback that updates the value prop in order for the component to reflect user actions. If the value prop is not updated, the component will continue to render the supplied value prop instead of the expected result of any user actions.
import { Switch } from 'react-native';
<Switch {...props} />;
API
Props
The color of the thumb grip when the switch is turned on. (Web-only)
The color of the track when the switch is turned on. (Web-only)
Disables interactions with the element. If true
, the user won’t be able to interact with the switch.
Invoked with the new value when the value changes.
The color of the thumb grip when the switch is turned off.
The color of the track when the switch is turned off.
The value of the switch. If true
the switch will be turned on.
Examples
Custom sizes can be created using styles.