Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

input-toggle-js

A simple JavaScript input toggle control.

chigozieorunta, npm, package, form, web, button, control, javascript, input, toggle, chigozie, orunta

readme

toggle.js

A simple JavaScript input toggle control.

NPM

You can install directly via NPM to your project folder.

npm install toggle-js

CDN

The CDN is updated after the release is made public. Always, check the GitHub page for the latest release.

Usage

Add a toggle control to your web pages easily by simply including an input element with type attribute as toggle like so:

<input type="toggle">

States (On & Off)

The default state for the toggle is Off (0). You can also set a default state by adding a value to the value attribute like so.

<input type="toggle" value="1">

If you set a non-zero value, the state defaults to an On state: