Skip to content

Repository files navigation

react-native-switch-toggle

Simple switch toggle component for react-native. This component supports horizontal switch toggle with animation with several options like start/end background colors, start/end circle colors, and duration for animation.

Npm VersionDownloadsCIcodecovcode style: prettierLICENSEPRs Welcomesupports iOSsupports Androidsupports webruns with expo

News

Current package is fully redesigned in 2.0.0. We recommend you to use this package version >=2.0.0.

Alternative

Do you enjoy using react-native-switch-toggle? Then think about using dooboo-ui which is our ui integrated ilbrary. It included SwitchToggle from 0.1.6.

yarn add doobo-ui

Props

necessarytypesdefault
switchOnbooleanfalse
onPressfunc() => {}
containerStylestyles{ width: 80, height: 40, borderRadius: 25 ... }
circleStylestyles{ width: 32, height: 32, borderRadius: 16 ... }
backgroundColorOnstring'black'
backgroundColorOffstring'#C4C4C4'
circleColorOnstring'white'
circleColorOffstring'#C4C4C4'
durationnumber300
typenumber0 - Normal switch, 1 - Switch with a text
buttonTextstringText on-top of the button
backTextRightstringText to appear in right side when button toggled to left
backTextLeftstringText to appear in left side when button toggled to right
buttonTextStylestylesStyles for text on the button
textRightStylestylesStyles for text in right
textLeftStylestylesStyles for text in left
buttonStylestylesStyles for the button
buttonContainerStylestylesStyles for button container
rightContainerStylestylesStyles for right text container
leftContainerStylestylesStyles for left text container

Getting started

$ npm install react-native-switch-toggle --save

importSwitchTogglefrom"react-native-switch-toggle";

Basic Style

<SwitchToggleswitchOn={on}onPress={()=>off(!on)}/>

Custom Color

<SwitchToggleswitchOn={on}onPress={()=>off(!on)}circleColorOff='#C4C4C4'circleColorOn='#00D9D5'backgroundColorOn='#6D6D6D'backgroundColorOff='#C4C4C4'/>

Custom Size

<SwitchToggleswitchOn={on}onPress={()=>off(!on)}containerStyle={{marginTop: 16,width: 106,height: 48,borderRadius: 25,padding: 5,}}circleStyle={{width: 40,height: 40,borderRadius: 20,}}/>

About

react-native switch toggle button component.

Topics

Resources

Contributing

Stars

126 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages