JSFiddle - React, Tailwind, and code Playground

by Torwan

HTML

<link rel="stylesheet" href="https://raubarrera.neocities.org/cdpn/style.css">
<div class="wrapper">
  <h1>Pure CSS Checkbox and Radio</h1>
  <h2>Checkbox</h2>
  <p><input type="checkbox" name="cb" id="cb1"><label for="cb1">Check and uncheck this</label></p>
  <h2>Radio</h2>
  <p><input type="radio" name="rd" id="rd1"><label for="rd1">Click this</label></p>
  <p><input type="radio" name="rd" id="rd2"><label for="rd2">Or click this</label></p>
</div>

CSS

body {
  background: #2c3e50;
}
/* Basic styles */
input[type="checkbox"],
input[type="radio"] {
  position: absolute;
  opacity: 0;
  z-index: -1;
}
label {
  position: relative;
  display: inline-block;
  padding: 0 0 0 2em;
  height: 1.5em;
  line-height: 1.5;
  cursor: pointer;
}
label::before,
label::after {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 1.5em;
  height: 1.5em;
}
label::before {
  content: " ";
  border: 2px solid blue;
  border-radius: 20%;
}
/* Checkbox */
input[type="checkbox"] + label::after {
  content: "\2714";
  color: pink;
  line-height: 1.5;
  text-align: center;
}
/* Radio */
input[type="radio"] + label::before {
  border-radius: 50%;
}
input[type=radio] + label::after {
  content: " ";
  top: .25em;
  left: .25em;
  width: 1em;
  height: 1em;
  background: #fff;
  border: .2em solid pink;
  border-radius: 50%;
}
/* :checked */
input[type="checkbox"]:checked + label::before,
input[type="radio"]:checked + label::before {
  background: red;
  border-color: darkblue;
}
input[type="checkbox"] + label::after,
input[type=radio] + label::after {
  -webkit-transform: scale(0);
  -ms-transform: scale(0);
  -o-transform: scale(0);
  transform: scale(0);
}
input[type="checkbox"]:checked + label::after,
input[type=radio]:checked + label::after {
  -webkit-transform: scale(1);
  -ms-transform: scale(1);
  -o-transform: scale(1);
  transform: scale(1);
}
/* Transition */
label::before,
label::after {
  -webkit-transition: .25s all ease;
  -o-transition: .25s all ease;
  transition: .25s all ease;
}