JSFiddle - React, Tailwind, and code Playground
HTML
<div class="checkbox">
<input class="css-checkbox" id="c11" name="c1" type="checkbox">
<label for="c11">Check</label>
</div>
CSS
.checkbox {
min-height: 24px;
margin-top: 6px;
position: relative;
}
input[type="checkbox"]:checked,
input[type="checkbox"]:not(:checked) {
box-sizing: border-box;
left: 4px;
margin: 0;
padding: 0;
position: absolute;
top: 3px;
}
input[type="checkbox"]:checked + label,
input[type="checkbox"]:not(:checked) + label {
background-color: #e0e0e0;
border-radius: 24px;
cursor: pointer;
display: inline-block;
height: 24px;
position: relative;
text-indent: -9999px;
-webkit-transition: background-color 0.3s;
transition: background-color 0.3s;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
width: 48px;
}
input[type="checkbox"]:checked + label:after,
input[type="checkbox"]:not(:checked) + label:after {
background-color: #fff;
border-radius: 20px;
content: " ";
height: 20px;
left: 2px;
position: absolute;
top: 2px;
-webkit-transition: -webkit-transform 0.3s;
-o-transition: -o-transform 0.3s;
transition: transform 0.3s;
width: 20px;
}
input[type="checkbox"]:checked + label {
background-color: #8c8;
}
input[type="checkbox"]:checked + label:after {
-webkit-transform: translateX(24px);
-ms-transform: translateX(24px);
-o-transform: translateX(24px);
transform: translateX(24px);
}