JSFiddle - React, Tailwind, and code Playground

HTML

<div style="height: 200px; width: 100px;" class="ck-button">
   <label class="ck-switch">
      <input type="checkbox" unchecked>
        <div style="background-color:#00cc00" class="on">red<br>on</div>
        <div style="background-color:#006600" class="off">Node red line that may overflow the 1234 width of the button<br>off<br>off<br>off<br>off<br>off<br>off<br>off<br>off<br>off<br>off<br>off<br>off<br>off<br>off</div>
    </label>
</div>

CSS

body {
padding: 10px;
background-color: #003;
} 
.ck-switch {
  position: relative;
  height: 100%;
/*  width: 100%;*/
}

.ck-switch input { display: none; }

.off {
  height: 100%;
/*  width: 100%;*/
  top: -100%;
  opacity: 1;
  color: white;
}
.on {
  height: 100%;
/*  width: 100%;*/
  color: white;
}
.ck-button input:checked + .on {
  opacity: 1;
  color: white;
}
.ck-button input + div + .off {
  opacity: 1;
  transform: translate(0, -100%);
}
.ck-button input:checked + div + .off {
  opacity: 0;
}


.ck-button {
  border-radius: 10px;
  height: 100%;
/*  width: 100%;*/
  overflow: hidden;
}

.ck-button:hover {
  border: 1px solid red;
}

.ck-button label {
  text-align: center;
}
.ck-button label div {
  white-space: normal;
  word-break: break-word;
  display: flex;
  align-items: center;
  justify-content: center;
}