JSFiddle - React, Tailwind, and code Playground

HTML

<input type="checkbox" id="slider-1"/><label for="slider-1"></label>

CSS

input[id^='slider-'] {
    display:none;
}

input[id^='slider-'] + label[for^='slider-'] {
    display: inline-block;
    width: 50px;
    height: 24px;
    position: relative;
    overflow: hidden;
    outline: 0 none;
    background-color: #337ab7;
    border-radius: 5px;
    border: 1px solid #000;
}

input[id^='slider-'] + label[for^='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[id^='slider-'] + label[for^='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[id^='slider-']:checked + label[for^='slider-']::after {
    left: 75%;
}

input[id^='slider-']:checked + label[for^='slider-']::before {
    left: 50%;
    right: 0px;
}