JSFiddle - React, Tailwind, and code Playground

by godsnake

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.j"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
  <div style="" class="container pb-2" id="signupForm">
  <div class="toggler pointer" id="filt-monthly">Monthly </div>
    <label class="toggle">
       <input type="checkbox" id="switcher" class="check"/>
       <b class="b switch"></b>
    </label>
  <div class="toggler pointer" id="filt-annual"> Annual</div>
</div>

 <div id="annually" class="hide wrapper-full">
 <div class="container bg-primary">
 
 <p class="text-white">
Hello This is priced annually 
 </p>
 </div>
 </div>
 
  <div id="monthly" class=" wrapper-full">
   <div class="container bg-secondary">
 
 <p class="text-white">
Hello This is priced monthly 
 </p>
 </div>
 </div>

CSS

.toggler {
  display: inline-block;
  vertical-align: middle;
  margin: 12px 0 0 0;
  color: #ddd;
  transition: .2s;
  font-weight: bold;
}
.toggler--is-active {
  color: #000000;
}
.b {
  display: block;
}
.hide{
  display: none;
}
/* slide/switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}
.toggle input { 
  opacity: 0;
  width: 0;
  height: 0;
}
.switch {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  cursor: pointer;
  background-color: #999;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 34px;
}
.switch:before {
  position: absolute;
  bottom: 4px; left: 4px;
  content: "";
  width: 26px;
  height: 26px;
  background-color: #fff;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .switch {
  background-color: #f66;
}
input:focus + .switch {
  box-shadow: 0 0 1px #f66;
}
input:checked + .switch:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

JavaScript

var month = document.getElementById("filt-monthly"),
    annual = document.getElementById("filt-annual"),
    swicther = document.getElementById("switcher"),
    montWrapper = document.getElementById("monthly"),
    annualWrapper = document.getElementById("annually");

month.addEventListener("click", function(){
  month.classList.add("toggler--is-active");
  annual.classList.remove("toggler--is-active");
  montWrapper.classList.remove("hide");
  annualWrapper.classList.add("hide");
  document.querySelector("[type='checkbox']").checked = false
});

 annual.addEventListener("click", function(){
  month.classList.remove("toggler--is-active");
  annual.classList.add("toggler--is-active");
  montWrapper.classList.add("hide");
  annualWrapper.classList.remove("hide");
  document.querySelector("[type='checkbox']").checked = true
}); 

swicther.addEventListener("click", function(event){
  month.classList.toggle("toggler--is-active");
  annual.classList.toggle("toggler--is-active");
  montWrapper.classList.toggle("hide");
  annualWrapper.classList.toggle("hide");
})