In this new version, I’ve rewritten the component model with some alignment for ES6. Also, I’ve added the disabled feature. You can see a Demo example here.

Installation

You can use React Switch Button by using NPM and include it in your own React build process (using Browserify, etc).

PHP

1

$ npm install react-switch-button --save

At this point you can import react-switch-button and its styles in your application as follows:

JavaScript

1

2

3

4

import Selectfrom'react-switch-button';

// Be sure to include styles at some point, probably during your bootstrapping

import'react-switch-button/dist/react-switch-button.css';

or

JavaScript

1

constSwitch=require('react-switch-button');

and then include the css in your HTML page.

Of course, you can also use the standalone build by including react-switch-button.js and react-switch-button.css in your page. (If you do this though you’ll also need to include the dependencies.) For example: