Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/segment-boneyard/toggle
A toggle UI element.
https://github.com/segment-boneyard/toggle
Last synced: about 5 hours ago
JSON representation
A toggle UI element.
- Host: GitHub
- URL: https://github.com/segment-boneyard/toggle
- Owner: segment-boneyard
- Created: 2013-07-11T01:56:53.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-08-26T21:21:33.000Z (about 10 years ago)
- Last Synced: 2024-04-09T16:31:15.376Z (7 months ago)
- Language: JavaScript
- Size: 202 KB
- Stars: 39
- Watchers: 39
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# toggle
A toggle UI element.
![on](https://i.cloudup.com/kjeyaT5oFH.png)
![off](https://i.cloudup.com/hEd5319GKt.png)## Installation
$ component install segmentio/toggle
## Example
```js
var Toggle = require('toggle');var toggle = new Toggle();
document.body.appendChild(toggle.el);toggle.value(); // false
toggle.value(true);
toggle.value(); // truetoggle.toggle();
toggle.value(); // false
```## API
### Toggle(value, el)
Create a new toggle with an optional starting `value` and optional `el` to use instead of creating one.### #el
The toggle's DOM element.```html
```### #value(val)
Get or set the value of the toggle.### #name(name)
Set the toggle's internal checkbox's name, so forms can be submitted properly.### #toggle()
Toggle the value of the toggle.### #label(on, off)
Set the on and off labels's HTML.### #addClass(name)
Add a class to the toggle's element.### #removeClass(name)
Remove a class from the toggle's element.## License
MIT