A simple and powerful iOS style switch for checkbox.
<link rel="stylesheet" href="dist/switchery.min.css" />
<script src="dist/switchery.min.js"></script>
$ npm install switchery.js
<input type="checkbox" class="checkbox-switch" />
standalone version
const el = document.querySelector('.checkbox-switch');
const switchery = new Switchery(el, options);
work with module bundle
import Switchery from 'switchery.js';
const el = document.querySelector('.checkbox-switch');
const switchery = new Switchery(el, options);
defaults = {
size: 'default',
color: '#64BD63',
secondaryColor: '#dfdfdf',
jackColor: '#fff',
jackSecondaryColor: null,
disabled: false,
disabledOpacity : 0.5,
speed: '0.4s',
className: 'switchery',
onInit: noop,
beforeChange: noop,
onChange: noop
};
size
: size of switch element, can bedefault
|small
|large
color
: color of checked switch elementsecondaryColor
: color of unchecked switch elementjackColor
: color of checked jack elementjackSecondaryColor
: color of unchecked jack elementdisabled
: enable or disable click events and changing the state of the switchonInit
: called when switch init finishbeforeChange
: called before original checkbox'schecked
changeonChange
: called when original checkbox'schecked
change
See if input is checked.
Set switch ON.
Set switch OFF.
Toggle switch.
Disable events bind to switch.
Enable events bind to switch.
Remove switch form DOM and show the checkbox.
Licensed under MIT