JSFiddle - React, Tailwind, and code Playground
HTML
<label class="slider"><input type="checkbox"/><span></span></label>
CSS
label.slider input {
display:none;
}
label.slider span {
display: inline-block;
width: 50px;
height: 24px;
position: relative;
overflow: hidden;
outline: 0 none;
background-color: #337ab7;
border-radius: 5px;
border: 1px solid #000;
}
label.slider span::before {
content: '';
display: inline-block;
position: absolute;
left: 0px;
height: 100%;
right: 50%;
background-color: #FFF;
transition: left 0.5s, right 0.5s;
z-index: 3;
}
label.slider span::after {
content: '';
display: inline-block;
position: absolute;
right: 0px;
height: 100%;
left: 25%;
background-color: #ccc;
z-index: 2;
transition: left 0.5s;
}
label.slider input:checked + span::after {
left: 75%;
}
label.slider input:checked + span::before {
left: 50%;
right: 0px;
}