JSFiddle - React, Tailwind, and code Playground
by António Almeida
HTML
<div class="switch"></div>
CSS
body {
background-color: #000;
}
.switch {
background-image: url(https://cdn.dribbble.com/users/98470/screenshots/419656/lighted_rocker_switch_v2.jpg);
width: 108px;
height: 206px;
background-position: -71px -48px;
}
.switch.active {
background-position: -222px -48px;
}
JavaScript
document
.getElementsByClassName('switch')[0]
.addEventListener("click", e => e.target.classList.toggle("active"));