A toggle UI element.
$ component install segmentio/toggle
var Toggle = require('toggle');
var toggle = new Toggle();
document.body.appendChild(toggle.el);
toggle.value(); // false
toggle.value(true);
toggle.value(); // true
toggle.toggle();
toggle.value(); // false
Create a new toggle with an optional starting value
and optional el
to use instead of creating one.
The toggle's DOM element.
<div class="toggle">
<label class="toggle-on-label"></label>
<div class="toggle-switch">
<input class="toggle-checkbox" type="checkbox">
</div>
<label class="toggle-off-label"></label>
</div>
Get or set the value of the toggle.
Set the toggle's internal checkbox's name, so forms can be submitted properly.
Toggle the value of the toggle.
Set the on and off labels's HTML.
Add a class to the toggle's element.
Remove a class from the toggle's element.
MIT