JSFiddle - React, Tailwind, and code Playground

by deswolf

HTML

<label class="control control__checkbox">
  Checkbox label 1
  <input type="checkbox">
  <i class="control__indicator"></i>
</label>
<div>

<label class="ts-checkbox">
  <input type="checkbox"><i>Label</i>
</label>

</div>

<label class="ts-checkbox">
  <input type="checkbox" disabled><i>Label</i>
</label>

SCSS

$disabled-color:#7b7b7b;
$font-size-control:16px;
$black5:black;
$input-gray:#E0E0E0;
$input-radius:2px;
$primary-color:blue;
$light-blue:lightblue;
$green:green;
$bg-green:lightgreen;
$control-size:16px;
label {
  font-size:12px;
  font-family:sans-serif;
}
.ts-checkbox, .ts-radio {
  display: inline-block;
  position: relative;
  padding-left: $control-size + 8px;
  cursor: pointer;
  font-size:$font-size-control;
  padding-top:3px;
  user-select:none;
  /* margin-right:5px; */
  input {
    position: absolute;
    z-index: -1;
    opacity: .5;
  }
  > i {
    font-style:normal;  
    &:before {
      content:"";
      position: absolute;
      top: 2px;
      left: 0;
      height: $control-size;
      width: $control-size;
      background: #fff;
      border:1px solid $input-gray;
      border-radius:$input-radius;
      display:block;
    }
  }
  &:hover input ~ i:before, input:focus ~ i:before {
    box-shadow:0 0 0 2px $light-blue !important;
    border-color:$light-blue;
  }
  input:checked ~ i:before {
    background:$primary-color;
    border-color:$primary-color;
  }
  input:disabled ~ i:before {
    background: #e6e6e6;
    opacity: 0.6;
    pointer-events: none;
    cursor:not-allowed;
  }
}
.ts-checkbox {
  input ~ i:after {
    content: '';
    position: absolute;
    display: none;
  }  
  input:checked ~ i:after {
    display:block;
    left: 5px;
    top: 4px;
    width: 5px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
  }
}
.control {
  display: inline-block;
  position: relative;
  padding-left: 30px;
  cursor: pointer;
  font-size:$font-size-control;
  padding-top:3px;
  user-select:none;
  margin-right:5px;
}
.control input {
  position: absolute;
  z-index: -1;
  opacity: 0;
}
.control__indicator {
  position: absolute;
  top: 2px;
  left: 0;
  height: $control-size;
  width: $control-size;
  background: #fff;
  border:1px solid $black5;
  border-radius:$input-radius;
 ...