0.1.4 • Published 6 years ago

react-native-toggle-switch v0.1.4

Weekly downloads
12
License
MIT
Repository
github
Last release
6 years ago

react-native-toggle-switch

Toggle Switch UI Component for React Native Apps ( iOS and Android Compatible )

Content

Features

  • Plug-n-Play, easy to use module
  • Supports multiple buttons as well
  • Light-weight and compatible with both iOS and Android

Installation

  • 1.Run npm i react-native-toggle-switch --save
  • 2.import ToggleSwitch from 'react-native-toggle-switch'

Demo

Screenshots

Getting started

To Get Started, Import react-native-toggle-switch to your js file.

import ToggleSwitch from 'react-native-toggle-switch'

Inside your component's render method, or any other method returning views, use ToggleSwitch:

<ToggleSwitch
    labels={ [ 'ON', 'OFF' ] }
    size={ 30 }
    onToggle={ (val) => console.log('changed to : ', val) }
/>;

API

PropsTypeOptionalDefaultDescription
labelsArray of Stringsfalse'false'Label which will appear on Toggle Switch Buttons
activeColorStringtrue'blue'Active Color
activeTextColorStringtrue'#fff'Text Color of Active Button
inactiveColorStringtrue'rgba(0, 0, 0, 0.5)'Inactive Color
inactiveTextColorStringtrue'#fff'Text Color of inactive Button
sizeNumbertrue30Size of the toggle switch button, maintains a 2:3 ratio of height:width
onToggleFunction CallbackfalsenoneCallback when the toggle switch component changes the state, Param: SwitchObject { index, label, state }

Contribution

If you encountered an Issue, please add a screenshot of the bug or a code snippet.

Quickest way to solve issue is to reproduce it on the example project

Pull requests are welcome. If you want to change the API or imporove something, feel free to create an issue and discuss it first.


MIT Licensed