JSFiddle - React, Tailwind, and code Playground
by Ayyappan Sakthivadivel
HTML
<label class="switch">
<input type="checkbox" class="switch-input"><!--<i class="icon-play"></i>-->
<span class="switch-label" data-on="Guide on" data-off="Guide me"></span>
<span class="switch-handle"></span>
</label>
CSS
.switch {
position: relative;
display: inline-block;
vertical-align: top;
width: 96px;
height: 36px;
padding: 1px;
border-radius: 3px;
cursor: pointer;
}
.switch-input {
position: absolute;
top: 0;
left: 0;
opacity: 0;
}
.switch-label {
position: relative;
display: block;
height: inherit;
font-size: 10px;
text-transform: uppercase;
background: #fff;
border-radius: inherit;
-webkit-transition: 0.15s ease-out;
-moz-transition: 0.15s ease-out;
-o-transition: 0.15s ease-out;
transition: 0.15s ease-out;
-webkit-transition-property: opacity background;
-moz-transition-property: opacity background;
-o-transition-property: opacity background;
transition-property: opacity background;
}
.switch-label:before, .switch-label:after {
position: absolute;
top: 50%;
margin-top: -.5em;
line-height: 1;
-webkit-transition: inherit;
-moz-transition: inherit;
-o-transition: inherit;
transition: inherit;
}
.switch-label:before {
content: attr(data-off);
right: 9px;
color: #aaa;
}
.switch-label:after {
content: attr(data-on);
left: 11px;
color: white;
opacity: 0;
}
.switch-input:checked ~ .switch-label {
background: #e57061;
}
.switch-input:checked ~ .switch-label:before {
opacity: 0;
}
.switch-input:checked ~ .switch-label:after {
opacity: 1;
}
.switch-handle {
position: absolute;
top: 1px;
left: -5px;
width: 36px;
height: 36px;
background: white;
border-radius: 3px;
-webkit-transition: left 0.15s ease-out;
-moz-transition: left 0.15s ease-out;
-o-transition: left 0.15s ease-out;
transition: left 0.15s ease-out;
border: #f0f0f0 solid 1px;
}
.switch-input:checked ~ .switch-handle {
left: 70px;
}
.switch-green > .switch-input:checked ~ .switch-label {
background: #4fb845;
}