Skip to content

Zola/switch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

switch

A switch UI for checkbox.

Build Status

switch

Showcase at http://yuehu.github.io/switch/.

Installation

Install with component(1):

$ component install yuehu/switch

API

var switcher = new Switch()

.label(on, off)

Text for on/off label. Define in Chinese:

switcher.label('开', '关')

.change(value)

Accept true and false. Change switcher to true or false.

.toggle()

Toggle on/off the swither.

.takeover(element)

The element should be a <input type="checkbox">. It will hide the given element, and when swither is on the checkbox will be checked.

.value()

Get or set value.

Events

When switcher value changes, it will emit a change event.

swither.on('change', function(value) {
  // value is true or false
})

Additional Note

You can change the button size by changing the font size of the label.

.switch {
  font-size: 14px;
}

License

MIT

About

A switch UI for checkbox.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 46.3%
  • CSS 24.5%
  • HTML 23.2%
  • Makefile 6.0%