JSFiddle - React, Tailwind, and code Playground
by AlexP11223
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<div id="div_checkbox">
<input type='checkbox' id='id_1' class='class_checkbox'>
<label for='id_1'></label>
<input type='checkbox' id='id_2' class='class_checkbox' checked>
<label for='id_2'></label>
</div>
CSS
#div_checkbox input[type="checkbox"] {
display: none;
}
#div_checkbox input[type="checkbox"]+label {
display: block;
position: relative;
width: 50px;
border-radius: 10px;
height: 22px;
border: 2px solid #f00;
padding-left: 5px;
margin: 5px 10px 20px 50px;
font: 14px/20px 'Open Sans', Arial, sans-serif;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
float: left;
}
#div_checkbox input[type="checkbox"]+label:last-child {
margin-bottom: 0;
}
#div_checkbox input[type="checkbox"]:checked + label {
text-align: left;
}
#div_checkbox input[type="checkbox"]:checked + label:after {
content: "Вкл";
}
#div_checkbox input[type="checkbox"]:not(:checked) + label {
text-align: right;
}
#div_checkbox input[type="checkbox"]:not(:checked) + label:after {
content: "Выкл";
}