1.1.3 • Published 8 years ago
react-toggleswitch v1.1.3
######################## Author - "Deep Prakash" ########################
React Toggle Switch
A full customizable Toggle switch. No Jquery.
Install
npm install react-toggleswitch --save
Usage
var Switch = require("react-toggleswitch");
React.render(<Switch />, document.getElementById("myApp"));
Options
- onValue
- offValue
- width
- onChange
- background
- toggleColor
Descriptions
onValue - Display value for ON state.
``` <Switch onValue = "ON"/> ```
offValue - Display value for OFF state.
``` <Switch offValue = "OFF"/> ```
width - Width of the switch.
``` <Switch width = "140"/> ```
onChange - Function for handling switch toggle.
``` <Switch onChange = {this.toggle} /> ``` ``` toggle:function(val){ if(val == "ON"){ /* Do something you need to do if switch is on */ } if(val == "OFF"){ /* Do something you need to do if switch is off */ } } ```
background - Set switch background color.
``` <Switch background = "#16a085"/> ```
toggleColor - Set switch toggle button color.
``` <Switch toggleColor = "#34495e" /> ```