react-toggle-switch
A simple iOS inspired toggle switch.
Install
npm install --save react-toggle-switch
Demo
https://patrickgrimard.io/react-toggle-switch/
Usage
;; { superprops; thisstate = switched: false ; } { this; }; { return <div> /* Basic Switch */ <Switch onClick=thistoggleSwitch on=thisstateswitched/> /* With children */ <Switch onClick=thistoggleSwitch on=thisstateswitched> <i class="some-icon"/> </Switch> /* Disabled */ <Switch onClick=thistoggleSwitch on=thisstateswitched enabled=false/> /* Custom classnames */ <Switch onClick=thistoggleSwitch on=thisstateswitched className='other-class'/> </div> ; } ;
Upgrading to version 3.0.0
Please take note that as of version 3.0.0, a Switch
no longer maintains an internal state. Using this component
requires that you pass both an onClick
method and an on
value to set the current state of the Switch
. More
details about why this was changed can be found here.
Props
onClick
- Function handler to be called any time the switch is clicked.on
- Sets the switch on or off.enabled
- If set tofalse
, the switch cannot be toggled. Default istrue
.className
- Optional CSS classes for the root element.
Import Styling