Lightweight switch implementation for Android and iOS.
url: https://snack.expo.io/@zhangbao90s/animated-switch-v3
Just copy AnimatedSwitch.tsx
's code from demo above to your project.
import AnimatedSwitch from './AnimatedSwitch';
<AnimatedSwitch value={false} onValueChange={(value) => console.log(value)} />;
Prop | Type | Optional | Default value | Description |
---|---|---|---|---|
value | Boolean | false | Default state. | |
onValueChange | Function | false | Trigger after switch state is changed. | |
width | Number | true | 54 | Switch width. |
height | Number | true | 30 | Switch height. |
onColor | String | true | dodgerblue | Active color. |
offColor | String | true | lightgray | Inactive color. |
MIT