JSFiddle - React, Tailwind, and code Playground

by Marc Malignan

HTML

<input id="c1" class="swicth" type="checkbox" checked="true" />
<label for="c1"></label>
<input id="c2" class="swicth" type="checkbox" />
<label for="c2"></label>

CSS

body {
    background: #efefef;
}

.swicth {
    display: none;
}

.swicth + label {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
    background: #d9534f;
    border-radius: 6px;
    border: 1px solid #d43f3a;
    cursor: pointer;
    transition: all .1s;
}
.swicth:checked + label {
    background: #5cb85c;
    border: 1px solid #4cae4c;
}

.swicth + label:before {
    content: 'non';
    display: block;
    width: 50%;
    float: right;
    line-height: 30px;
    text-align: center;
    font-family: arial;
    font-size: 12px;
    font-weight: bold;
    color: white;
}
.swicth:checked + label:before {
    content: 'oui';
    float: left;
}

.swicth + label:after {
    content: '';
    position: absolute;
    top:1px; left:1px; bottom:1px;
    width: 28px;
    border-radius: 4px;
    background: white;
    transition: all .1s;
}
.swicth:checked + label:after {
    left:31px;
}