JSFiddle - React, Tailwind, and code Playground

by Narottam Goyal

HTML

<label class="checkboxcontainer"> one
  <input type="checkbox" disabled>
  <span class="checkmark"></span>
</label>

<br/>
<br/>
<label class="checkboxcontainer"> one
  <input type="checkbox" disabled checked>
  <span class="checkmark"></span>
</label>

<br/>
<br/>


<label class="checkboxcontainer"> one
  <input type="checkbox">
  <span class="checkmark"></span>
</label>

CSS

.checkboxcontainer input {
  display: none;
}

.checkboxcontainer {
  display: inline-block;
  padding-left: 30px;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.checkboxcontainer .checkmark {
  display: inline-block;
  width: 20px;
  height: 20px;
  background: white;
  position: absolute;
  left: 0;
  top: 0;
  border: 1px solid black;
}

.checkboxcontainer input:checked + .checkmark {
  background-color: #1390e5;
  border: 1px solid #1390e5;
}

.checkboxcontainer input:indeterminate + .checkmark {
  background-color: #1390e5;
  border: 1px solid #1390e5;
}

.checkboxcontainer input:checked + .checkmark:after {
  content: "";
  position: absolute;
  height: 6px;
  width: 11px;
  border-left: 2px solid white;
  border-bottom: 2px solid white;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-45deg);
}

.checkboxcontainer input:checked:disabled + .checkmark {
    border: 1px solid grey;
    background-color: grey;
}

.checkboxcontainer input:disabled + .checkmark {
    border: 1px solid grey;
}

.checkboxcontainer input:indeterminate + .checkmark:after {
  content: "";
  position: absolute;
  height: 0px;
  width: 11px;
  border-left: 2px solid white;
  border-bottom: 2px solid white;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(180deg);
}