JSFiddle - React, Tailwind, and code Playground

by terby

HTML

<label class="switch"><input type="checkbox" checked="checked" />
    <div class="button">
        <div class="light"></div>
        <div class="dots"></div>
        <div class="characters"></div>
        <div class="shine"></div>
        <div class="shadow"></div>
    </div>
</label>

CSS

body,
html {
  width: 100%;
  height: 100%;
}

body {
  background-color: #fafcff;
  background-image: radial-gradient(circle, transparent, #afb5bf), linear-gradient(transparent, #d3d8e0);
  display: flex;
  align-items: center;
  justify-content: center;
}

.switch {
  background-color: black;
  width: 75px;
  height: 100px;
  box-shadow: 0 0 10px 2px rgba(0, 0, 0, 0.2), 0 0 1px 2px black, inset 0 2px 2px -2px white, inset 0 0 2px 15px #47434c, inset 0 0 2px 22px black;
  border-radius: 5px;
  padding: 22px;
  perspective: 700px;
}

.switch input {
  display: none;
}

.switch input:checked+.button {
  transform: translateZ(90px) rotateX(30deg);
  box-shadow: 0 -10px 20px #ff1818;
}

.switch input:checked+.button .light {
  animation: flicker 0.2s infinite 0.3s;
}

.switch input:checked+.button .shine {
  opacity: 1;
}

.switch input:checked+.button .shadow {
  opacity: 0;
}

.switch .button {
  transition: all 0.3s cubic-bezier(1, 0, 1, 1);
  transform-origin: center center -10px;
  transform: translateZ(90px) rotateX(-30deg);
  transform-style: preserve-3d;
  background-color: #9b0621;
  width: 100%;
  height: 100%;
  position: relative;
  cursor: pointer;
  background: linear-gradient(#980000 0%, #6f0000 30%, #6f0000 70%, #980000 100%);
  background-repeat: no-repeat;
}

.switch .button::before {
  content: "";
  background: linear-gradient(rgba(255, 255, 255, 0.8) 10%, rgba(255, 255, 255, 0.3) 30%, #650000 75%, #320000) 50% 50% / 97% 97%, #b10000;
  background-repeat: no-repeat;
  width: 100%;
  height: 30px;
  transform-origin: top;
  transform: rotateX(-80deg);
  position: absolute;
  top: 0;
}

.switch .button::after {
  content: "";
  background-image: linear-gradient(#650000, #320000);
  width: 100%;
  height: 30px;
  transform-origin: top;
  transform: translateY(30px) rotateX(-100deg);
  position: absolute;
  bottom: 0;
  box-shadow: 0 30px 8px 0px black, 0 80px 20px 0px rgba(0, 0, 0, 0.5);
}

.switch .light {
  opacity: 0;
  animation: light-off 1s;
 ...

JavaScript

// SMALLER