JSFiddle - React, Tailwind, and code Playground
HTML
<h1>Кастомный чекбокс</h1>
<input class="checkbox-hidden" type="checkbox" id="mail" />
<label class="checkbox-slider" for="mail"></label>
Получать почту
CSS
label
{
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.checkbox-hidden
{
display: none;
}
.checkbox-slider
{
position: relative;
display: inline-block;
width: 50px;
height: 30px;
margin-right: 10px;
-webkit-transition: background-color .2s;
transition: background-color .2s;
vertical-align: -10px;
border-radius: 20px;
background: #eee;
box-shadow: inset 0 0 5px rgba(0,0,0,.5);
}
.checkbox-slider::before
{
position: absolute;
top: 0;
left: 0;
display: block;
width: 30px;
height: 30px;
content: '';
-webkit-transition: left .2s;
transition: left .2s;
border-radius: 100%;
background: #fff;
box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.checkbox-hidden:checked + .checkbox-slider
{
border-color: #64bd63;
background-color: #64bd63;
}
.checkbox-hidden:checked + .checkbox-slider::before
{
left: 20px;
}