JSFiddle - React, Tailwind, and code Playground
by yoowordpress
HTML
<span class="wpp-switch">
<input type="checkbox" id="s5" checked="">
<label for="s5" data-on="On" data-off="Off"></label>
</span>
CSS
.wpp-switch label {
margin: 0;
line-height: normal;
font-family: inherit;
font-size: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box
}
.wpp-switch::-moz-focus-inner {
padding: 0 !important;
border: 0 !important
}
.wpp-switch {
display: inline-block;
vertical-align: top;
position: relative;
width: 58px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none
}
.wpp-switch>label {
display: block;
position: relative;
height: 25px;
line-height: 20px;
font-size: 10px;
font-weight: bold;
color: #bbb;
text-align: center;
text-transform: uppercase;
background: white;
border: 2px solid #d9d9d9;
border-radius: 13px;
-webkit-transition: 0.15s ease-out;
-moz-transition: 0.15s ease-out;
-o-transition: 0.15s ease-out;
transition: 0.15s ease-out
}
.wpp-switch>label:before {
content: attr(data-off);
position: absolute;
top: 0;
right: 3px;
width: 33px
}
.wpp-switch>label:after {
content: '';
display: block;
margin: 2px;
width: 17px;
height: 17px;
background: #ccc;
border-radius: 13px
}
.wpp-switch>input {
position: absolute;
top: 0;
left: 0;
width: inherit;
height: inherit;
opacity: 0;
-webkit-appearance: none
}
.wpp-switch>input:focus {
outline: none
}
.wpp-switch>input:focus+label {
color: #10a4ee;
border-color: #3fb6f2
}
.wpp-switch>input:focus+label:after {
background: #3fb6f2
}
.wpp-switch>input:checked+label {
padding-left: 33px;
color: white;
background: #3fb6f2;
border-color: #3fb6f2
}
.wpp-switch>input:checked+label:before {
content: attr(data-on);
left: 1px
}
.wpp-switch>input:checked+label:after {
margin: 1px;
width: 19px;
height: 19px;
background: white
}
.wpp-switch>input:checked:focus+label {
background: #10a4ee;
...