A switch UI for checkbox.
Showcase at http://yuehu.github.io/switch/.
Install with component(1):
$ component install yuehu/switch
var switcher = new Switch()
Text for on/off label. Define in Chinese:
switcher.label('开', '关')
Accept true
and false
. Change switcher to true or false.
Toggle on/off the swither.
The element should be a <input type="checkbox">
. It will hide the given
element, and when swither is on the checkbox will be checked.
Get or set value.
When switcher value changes, it will emit a change
event.
swither.on('change', function(value) {
// value is true or false
})
You can change the button size by changing the font size of the label.
.switch {
font-size: 14px;
}
MIT