2.2.1 • Published 3 years ago

react-native-switch-toggle v2.2.1

Weekly downloads
1,493
License
MIT
Repository
github
Last release
3 years ago

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 Version Downloads CI codecov code style: prettier LICENSE PRs Welcome supports iOS supports Android supports web runs 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

import SwitchToggle from "react-native-switch-toggle";

Basic Style

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

Custom Color

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

Custom Size

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

3 years ago

2.2.0

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago