JSFiddle - React, Tailwind, and code Playground

HTML

<div class="onoffswitch">
  <input type="checkbox" name="onoffswitch" id="myonoffswitch" checked>
  <label for="myonoffswitch">
    <span></span>
    <span></span>
  </label>
</div>
<!-- zweiter Toggle-Button mit anderem name-Attributwert: -->
<div class="onoffswitch">
  <input type="checkbox" name="onoffswitch2" id="myonoffswitch2" checked>
  <label for="myonoffswitch2">
    <span></span>
    <span></span>
  </label>
</div>

CSS

/* Toogle-Button GEYSER ON/OFF */

/* Das Elternelement, das den Button realisiert */
.onoffswitch {
  position: relative;
  width: 140px;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* das <input> Element */
.onoffswitch input {
 position: absolute !important;
 height: 1px; width: 1px;
 overflow: hidden;
 clip: rect(1px, 1px, 1px, 1px);
}

/* das <label> Element */
.onoffswitch label {
  display: block;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid #999999;
  border-radius: 20px;
}

/* das erste <span> Element */
.onoffswitch span:nth-of-type(1) {
  display: block;
  width: 200%;
  margin-left: -100%;
  transition: margin 0.3s ease-in 0s;
}

.onoffswitch span:nth-of-type(1):before,
.onoffswitch span:nth-of-type(1):after {
  display: block;
  float: left;
  width: 50%;
  height: 40px;
  padding: 0;
  line-height: 40px;
  font-size: 14px;
  color: white;
  font-family: Trebuchet, Arial, sans-serif;
  font-weight: bold;
  box-sizing: border-box;
}

.onoffswitch span:nth-of-type(1):before {
  content: "GEYSER ON";
  padding-left: 10px;
  background-color: #0000FF; color: #FFFFFF;
}

.onoffswitch span:nth-of-type(1):after {
  content: "GEYSER OFF";
  padding-right: 10px;
  background-color: #FF0000;
  color: #00FF00;
  text-align: right;
}

/* das zweite <span> Element */
.onoffswitch span:nth-of-type(2) {
  display: block;
  width: 20px;
  margin: 10px;
  background: #FFFFFF;
  position: absolute;
  top: 0;
  bottom: 0;
  right: 96px;
  border: 2px solid #999999;
  border-radius: 20px;
  transition: all 0.3s ease-in 0s; 
}

.onoffswitch input:checked + label span:nth-of-type(1) {
  margin-left: 0;
}

.onoffswitch input:checked + label span:nth-of-type(2) {
  right: 0px; 
}