JSFiddle - React, Tailwind, and code Playground

by XTREME104

HTML

<input type="checkbox" data-icon1="ON" data-icon2="OFF" checked>
<input type="checkbox" data-icon1="ON" data-icon2="OFF">

CSS

/* ----------- Checkbox */


input[type="checkbox"] {
    -webkit-appearance:none;    /* Remove Safari default */
    outline: none;
    width: 96px;
    height: 32px;
    position: relative;
    border-radius: 60px;
    background-color: #333;
    -webkit-background-clip: padding-box;    
    border: 0;
}

input[type="checkbox"]:before, input[type="checkbox"]:after {
    font: bold 16px/30px sans-serif;
    cursor: pointer;
    text-shadow: 0 1px 1px rgba(0,0,0,.2);    
    text-align: center;    
    position: absolute;
    z-index: 1;    
    width: 32px;
    height: 30px;
    top: 1px;    
    border: 0;
}

input[type="checkbox"]:after {
    content: attr(data-icon1);
    left: 1px;
    border-radius: 60px 0 0 60px;
}

input[type="checkbox"]:before {
    content: attr(data-icon2);
    right: 1px;
    border-radius: 0 60px 60px 0;
}


/* ----------- checked/unchecked */

/* unchecked */
input[type="checkbox"] {
    background: #fff;
}
input[type="checkbox"]:after {
    background: #fff;
}


/* checked */
input[type="checkbox"]:checked:after {
    background: #39c;
    color: #fff;
}

/* ----------- active/inactve */

/* Active */
input[type="checkbox"]:before, input[type="checkbox"]:checked:after {
    color: white;
    z-index: 2;  
    text-indent: 0;
    box-shadow: inset 0 0 3px 2px rgba(0,0,0,.1), inset 0 15px 0 rgba(0,0,0,.1);
    width: 70px;
    z-index: 0;
}

input[type="checkbox"]:before {
    padding-left: 10px;
    color: #666;
    text-shadow: 0 1px 0 rgba(255,255,255,.9);
}

input[type="checkbox"]:checked:after {
    padding-right: 20px;
}

/* Inactive */
input[type="checkbox"]:after, input[type="checkbox"]:checked:before {
    background: white -webkit-gradient(linear, 0% 0%, 0% 100%, from(#D1D1D1), to(white));
    text-indent: -9999px;
    border-radius: 60px;
    z-index: 99;
    width: 30px;
    height: 28px;
    box-shadow: inset 0 1px 2px rgba(255,255,255,1);
    border: 1px solid #888;
    padding: 0;
}