JSFiddle - React, Tailwind, and code Playground
HTML
<div id="switch" class="setting-switch"></div>
CSS
.setting-switch
{
transition: 300ms ease-in-out;
position: relative;
width: 46px;
height: 28px;
border-radius: 28px;
background-color: white;
margin: 10px;
border: 2px solid #E6E6E6;
}
.setting-switch:before
{
transition: 300ms ease-in-out;
content: '';
display: block;
width: 28px;
height: 28px;
border-radius: 28px;
background-color: #fff;
position: absolute;
top: 0;
left: 0;
box-shadow: 0 6px 4px rgba(0, 0, 0, 0.1), 0 -1px 2px rgba(0, 0, 0, 0.1);
}
.setting-switch.on
{
transition: 300ms ease-in-out;
background-color: #4CD964;
border: 2px solid #4CD964;
}
.setting-switch.on:before
{
transition: 300ms ease-in-out;
left: 18px;
}
JavaScript
var s = $("#switch")
s.click(function() {
s.toggleClass("on");
});