GithubHelp home page GithubHelp logo

toggle's Introduction

toggle

A toggle UI element.

on off

Installation

$ component install segmentio/toggle

Example

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

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.

<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>

#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

toggle's People

Contributors

ianstormtaylor avatar lancejpollard avatar calvinfo avatar

Stargazers

 avatar jason avatar Mingo avatar 曹文忠 avatar Daniel Torres avatar Daniel Fagnan avatar Enrico Marino avatar Alexandru Vlăduţu avatar Neil Jagdish Patel avatar Alexander Solovyov avatar Alex Carpenter avatar Kevin Luikens avatar  avatar Alex Mingoia avatar matthiasg avatar Eivind Fjeldstad avatar Ricky Rauch avatar Cristian Douce avatar Arnout Kazemier avatar Fabi avatar Amir Abushareb avatar Andrei Rosca avatar Daniel Chatfield avatar  avatar Markuso avatar Arkadiusz Szaleniec avatar Ni0rd avatar Olivier Refalo avatar Chee Aun avatar Alexey Kucherenko avatar Blake Embrey avatar Brian Chu avatar 迁移到 leogiese avatar Adrian Olaru avatar Kevin Coughlin avatar Mike Vegeto avatar Young avatar Matt Mueller avatar TJ Holowaychuk avatar

Watchers

Prakash Durgani avatar david birdsong avatar Michael Schmatz avatar James Cloos avatar Achille avatar Andrius Vaskys avatar Julien Fabre avatar George Wolf avatar Rakesh Nair avatar  avatar Gurdas Nijor avatar  avatar Karthick Sriraman avatar  avatar Niels avatar  avatar Sam Johnson avatar  avatar  avatar Sherry Chao avatar Nellie Ann avatar Michael Phillips avatar Christopher Albanese avatar Brent Summers avatar Alex Noonan avatar Teresa Nesteby avatar Chris Nixon avatar  avatar  avatar Zeb avatar Liz Hartmann avatar Arlen McCluskey avatar  avatar Ian Muceus avatar  avatar Emilio Gomez Lavin avatar  avatar Kate Flaming avatar  avatar

toggle's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.