GithubHelp home page GithubHelp logo

miladd3 / clean-switch Goto Github PK

View Code? Open in Web Editor NEW
23.0 2.0 5.0 611 KB

Clean Switch - Material Inspired Pure CSS toggle switch

Home Page: https://miladd3.github.io/clean-switch/

License: MIT License

CSS 50.91% JavaScript 3.25% SCSS 45.84%
css3 css toggle-switches material-design toggle-buttons ios-toggle css-toggle-switch switch-ellement

clean-switch's Introduction

clean-switch

Clean Switch - Material Inspired Pure CSS toggle switch

About

Clean switch is just a lightweight pure css toggle switch. witch is simillar to Material Design lite switch(MDL) But in pure css and better syntax and no dependency

How to use

First copy clean-switch.css in your project. then link it to your project HTML file

<link rel="stylesheet" href="clean-switch.css">

You can also use SCSS file clean-switch.scss

Make HTML switch structure like this. and put it inside forms or anywhere you like and it will behave like checkboxes.

<label class="cl-switch">
    <input type="checkbox" >
    <span class="switcher"></span>
    <span class="label">this is label</span>
</label>

Diffrent Sizes

To adjust size of switch just add classes to the list of classes in switch ellement

<label class="cl-switch cl-switch-large">
    <input type="checkbox" >
    <span class="switcher"></span>
    <span class="label">this is large switch</span>
</label>

size classes are:

  • cl-switch-large
  • cl-switch-xlarge

Disabled

to make a switch disable simply add disabled attribute to checkbox

<label class="cl-switch">
	<input type="checkbox" disabled>
	<span class="switcher"></span>
	<span class="label">Disabled</span>
</label>

Diffrent Colors

To adjust color of the switch just add classes to the list of classes in switch ellement

<label class="cl-switch cl-switch-red">
    <input type="checkbox" >
    <span class="switcher"></span>
    <span class="label">this is red switch</span>
</label>

color classes are:

  • cl-switch-black
  • cl-switch-red
  • cl-switch-green
  • cl-switch-orange

Custom Colors

For Some projects you will need custom color so you can do it with small CSS

1- first you should add a class to class list of cl-switch in this example its custom-class

<label class="cl-switch custom-class">
    <input type="checkbox" >
    <span class="switcher"></span>
    <span class="label">this is custom color switch</span>
</label>

2- then you should adjust its color in your css that is loaded after cl-switch css

.custom-class input[type="checkbox"]:checked + .switcher {
  background: #c06651; /*this is body of switch that should be lighter color*/
}
.custom-class input[type="checkbox"]:checked + .switcher:before {
  background: #c0392b; /*this is btn of switch that should be darker color*/
}

iOS Style

If you are an iOS fan, you can have iOS style too

just add ios class in label class list

all sizing and colors works fine

<label class="cl-switch ios">
	<input type="checkbox">
	<span class="switcher"></span>
	<span class="label">title</span>
</label>

licence and cast

MIT Licence

by Milad Dehghan

clean-switch's People

Contributors

dependabot[bot] avatar miladd3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

clean-switch's Issues

How to reverse toggle so ON is a right toggle action

Hi there,

Congratulations on such a cool library, we're using it inside our task.io desktop admin area - many thanks ๐Ÿ‘

My question is - any reason for making the on position to the left? Most UX says that ON = to the right.

I'd like to reverse it so the right position is ON, is there any easy way to do this?

Kind regards, Steve.

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.