JSFiddle - React, Tailwind, and code Playground

by bizamajig

HTML

<input type="checkbox" id="me" /> <label for="me"></label>

CSS

body {
    padding: 1em;
}

label {
    display: block;
    border-radius: 5em;
    position: relative;
    background-color: #F00;
    width: 15em; height: 5em;
    transition: background 1s;
}

label::before {
    content: "";
    border-radius: 50%;
    position: absolute;
    transition: left 1s;
    display: inline-block;
    background-color: #F66;
    top: -.25em; left: -.25em;
    width: 5.5em; height: 5.5em;
}

input {
    display: none;
}

input:checked + label {
    background: #900;
}

input:checked + label::before {
    left: 9.75em;
}