JSFiddle - React, Tailwind, and code Playground

HTML

<input type="checkbox" class="slider">

CSS

/* Checkbox as Toggle */
input[type="checkbox"].slider {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    -ms-appearance: none;
    width: 50px;
    height: 24px;
    position: relative;
    overflow: hidden;
    outline: 0 none;
    background-color: #337ab7;
    border-radius: 5px;
    border: 1px solid #000;
}

input[type="checkbox"].slider::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;
}

input[type="checkbox"].slider::after {
    content:  '';
    display: inline-block;
    position: absolute;
    right: 0px;
    height: 100%;
    left: 25%;
    background-color: #ccc;
    z-index: 2;
    transition: left 0.5s;
}

input[type="checkbox"].slider:checked::after {
    left: 75%;
}

input[type="checkbox"].slider:checked::before {
    left: 50%;
    right: 0px;
}