Accessible Performant Toggle Switch In Pure JavaScript

Category: Form , Javascript | October 27, 2018
Author: aeolingamenfel
Views Total: 2,749
Official Page: Go to website
Last Update: October 27, 2018
License: MIT

Preview:

Accessible Performant Toggle Switch In Pure JavaScript

Description:

Just another JavaScript plugin for creating iOS- and Material Design-style on/off switches from regular checkbox elements.

How to use:

Place the following JavaScript and CSS files into the html file.

<link href="SimpleSwitch.css" rel="stylesheet">
<script src="SimpleSwitch.min.js"></script>

Add the data-type="simple-switch" attribute to the checkbox element wrapped in a label element as this:

<label>
  <input type="checkbox" data-type="simple-switch">
  JavaScript
</label>

To create a Material Design toggle switch, just add the data-material=”true” to the checkbox:

<label>
  <input type="checkbox" data-type="simple-switch" data-material="true">
  JavaScript
</label>

Changelog:

v0.5.0 (10/27/2018)

  • Fixed bug where change event wouldn’t fire when Switch changed

You Might Be Interested In:


Leave a Reply