JSFiddle - React, Tailwind, and code Playground

by Stasweb

HTML

<div class="control-group">
<input type="checkbox" name="extra_fields[<?php echo $ch_id?>][] cb" id="cb1" value="<?php echo $val_id;?>"
<?php if (is_array($extra_fields_active[$ch_id]) && in_array($val_id, $extra_fields_active[$ch_id])) echo "checked";?> />
<label class="chura" for="cb1"><span><?php echo $val_name;?></span></label>
</div>

CSS

.control-group {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
}
input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  z-index: -1;
}
label {
  position: relative;
  display: inline-block;
  margin-right: 10px;
  margin-bottom: 10px;
  padding-left: 30px;
  padding-right: 10px;
  line-height: 36px;
  cursor: pointer;
}
label::before {
  content: " ";
  position: absolute;
  top: 6px;
  left: 0;
  display: block;
  width: 24px;
  height: 24px;
  border: 2px solid #436ca2;
  border-radius: 4px;
  z-index: -1;
}

/* Checked */
input[type="checkbox"]:checked + label {
  padding-left: 10px;
  color: #fff;
}
input[type="checkbox"]:checked + label::before {
  top: 0;
  width: 100%;
  height: 100%;
  background: #436ca2;
}
/* Transition */
label,
label::before {
  -webkit-transition: .25s all ease;
  -o-transition: .25s all ease;
  transition: .25s all ease;
}