Clean switch is just a lightweight pure css toggle. witch is simillar to Material Design lite switch(MDL) But in pure css and better syntax and no dependency
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>
For More options like color and sizes see examples blow
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:
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>
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:
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*/
}
if you are an iOS fan, you can have iOS style too and all sizing and colors works fine with iOS too
<label class="cl-switch ios">
<input type="checkbox">
<span class="switcher"></span>
<span class="label">title</span>
</label>
1Dgn64K6X6F9FfZ1tcAkfYKZTtPnrWp57h
0x611d47A21e24971AE240CF4bA076a8dF78330FbF