1.2.5 • Published 4 years ago

react-native-switches v1.2.5

Weekly downloads
494
License
MIT
Repository
github
Last release
4 years ago

react-native-switches

npm

Customizable Switch components for react native

Using:

Installation

npm install --save react-native-switches

or

yarn add react-native-switches

Demo

pill-switch line-switch

Usage

Basic usage requires choosing between the line and pill shapes.

  • line : requires the user to choose and to confirm a PIN code
  • pill : requires the user to enter the PIN code he previously chose It also requires you to provide a boolean value for the switch and an onChange function.
import Switches from 'react-native-switches'
<Switches shape={'pill'} onChange={() => this.setState({switchValue: !this.state.switchValue})} value={this.state.switchValue}/>

Options

KeyDescriptionDefaultRequiredType
animationDurationDuration of the transition animation300falsenumber
borderColorColor of the border of the switch#D3D5DAfalsestring
borderWidthWidth of the border of the switch1falsenumber
buttonColorColor of the button of the switchLine shape: #96CBCE / Pill shape: #FFFfalsestring
buttonOffsetLeftDifference between the maximum left position of the button and the maximum left position of the slideLine shape: 0 / Pill shape: 2falsenumber
buttonOffsetRightDifference between the maximum right position of the button and the maximum right position of the slideLine shape: 0 / Pill shape: 2falsenumber
buttonSizeHeight and width of the button of the switchLine shape: 20 / Pill shape: 32falsenumber
colorSwitchOffColor of the slide when the switch is on off positionLine shape: #E8EAEC / Pill shape: #D3D5DAfalsestring
colorSwitchOnColor of the slide when the switch is on on positionLine shape: #E8EAEC / Pill shape: #96CBCEfalsestring
colorTextOffColor of the text when the switch is on off positionLine shape: #E8EAEC / Pill shape: #445878falsestring
colorTextOnColor of the text when the switch is on on positionLine shape: #7BCDD0 / Pill shape: #FFFfalsestring
disabledBoolean disabling the click on the buttonfalsefalseboolean
easingFunctionEasing function for the animationeaseQuadIn d3-ease functionfalsefunction
iconIcon to be placed on the buttonNonefalseany
onChangeFunction triggered when the switch is tappedNonetruefunction
paddingTextOffPadding right foe the off text on pill switchPill shape: 0falsenumber
paddingTextOnPadding left for the on text on pill switchPill shape: 0falsenumber
shapeShape of the switch (line or pill)NonetrueShapes enum
showTextBoolean indicating if the text should be visible or nottruefalseboolean
sliderHeightHeight of the slider of the switchLine shape: 6 / Pill shape: 36falsenumber
sliderWidthWidth of the slider of the switchLine shape: 30 / Pill shape: 70falsenumber
spaceBetweenSpace between the two texts of the switchLine shape: 10 / Pill shape: 10falsenumber
testIDText used for the testID property of the buttonreactNativeSwitchesfalsestring
textFontFont used for the text of the switchcourierfalsestring
textOffText used for the off position of the switchLine shape: No / Pill shape: offfalsestring
textOnText used for the on position of the switchLine shape: Yes / Pill shape: onfalsestring
textSizeSize of the text14falsenumber
valueBoolean value of the switch matching its position (true is on)Nonetrueboolean

Contributing

Pull requests are welcome.

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago