custom toggle button beginner

by Saksham Malhotra

HTML

<div class="toggle">
  <input type="checkbox" class="hidden" id="toggleRadio">
  <label for="toggleRadio">
    <span class="state"></span>
  </label>
</div>

CSS

.toggle {
  height: 36px;
  width: 80px;

}

.hidden {
  display: none;
}

.toggle label {
  width: 100%;
  height: 100%;
  background-color: #ddd;
  display: block;
  border-radius: 18px;
  position: relative;
  border: 4px solid #ddd;
  box-sizing: border-box;
  cursor: pointer;
  transition: background-color 0.3s, border-color 0.3s;
}

.toggle input+label .state {
  position: absolute;
  height: 28px;
  width: 28px;
  border-radius: 50%;
  background-color: #fff;
  transform: translate(0%, -50%);
  top: 50%;
  margin-left: 0;
  right: auto;
  transition: margin-left 0.3s;
}

.toggle input:checked+label {
  background-color: #6cc04a;
  border-color: #6cc04a;
}

.toggle input:checked+label .state {
  margin-left: 60%;
}