JSFiddle - React, Tailwind, and code Playground
by piiantom
HTML
<div>
<label class="switch">
<input type="checkbox" aria-label="..." />
<span><b>Switch me</b></span>
</label>
</div>
<br/>
<div>
<label class="switch small">
<input type="checkbox" aria-label="..." />
<span><b>Switch me</b></span>
</label>
</div>
CSS
.switch{
cursor: pointer;
}
.switch input[type="checkbox"] {
display: none;
}
.switch span {
position: abso
font-family: Arial;
font-size: 1rem;
line-height: 16px;
display: inline-block;
vertical-align: middle;
}
.switch span:before {
content: ''; display: inline-block;
vertical-align: middle;
width: 30px;
height: 16px;
background-color: #919eb7;
margin-right: 16px;
border-radius: 10px;
-moz-transition: background-color 500ms cubic-bezier(0.19, 1, 0.22, 1);
-ms-transition: background-color 500ms cubic-bezier(0.19, 1, 0.22, 1);
-o-transition: background-color 500ms cubic-bezier(0.19, 1, 0.22, 1);
transition: background-color 500ms cubic-bezier(0.19, 1, 0.22, 1);
}
.switch span:after{
content: ''; display: block;
position: absolute;
height: 12px; width: 12px;
background-color: #fff;
left: 2px; top: calc(50% - 6px);
border-radius: 50%;
box-shadow: 0 3px 5px 0 rgba(4, 18, 27, .2);
-moz-transition: all 500ms cubic-bezier(0.19, 1, 0.22, 1);
-ms-transition: all 500ms cubic-bezier(0.19, 1, 0.22, 1);
-o-transition: all 500ms cubic-bezier(0.19, 1, 0.22, 1);
transition: all 500ms cubic-bezier(0.19, 1, 0.22, 1);
}
.switch span b{
font-weight: normal; display: inline-flex;
vertical-align: middle;
}
/* .switch span b:before{
content: ''; display: inline-block; vertical-align: middle;
width: 5px; height: 5px;
background-color: #000;
border-radius: 50%;
margin-right: 12px;
-moz-transition: background-color 500ms cubic-bezier(0.19, 1, 0.22, 1);
-ms-transition: background-color 500ms cubic-bezier(0.19, 1, 0.22, 1);
-o-transition: background-color 500ms cubic-bezier(0.19, 1, 0.22, 1);
transition: background-color 500ms cubic-bezier(0.19, 1, 0.22, 1);
}*/
.switch input[type="checkbox"]:checked+span:before {
background-color: #0a5499;
}
.switch input[type="checkbox"]:checked+span:after {
box-shadow: 0 3px 5px 0 rgba(4, 18, 27, .57);
transform: translateX(13px);
}
/* .switch...