JSFiddle - React, Tailwind, and code Playground
HTML
<input type="checkbox" name="checkbox" id="checkbox-id" />
<label for="checkbox-id"></label>
CSS
input {
display: none;
}
label {
background-color: orange;
width: 100px;
height: 100px;
display: block;
}
input:checked label {
background-color: green;
}
JavaScript
var checkbox = document.getElementById('checkbox-id');
window.addEventListener('click', function(e) {
console.log(checkbox.checked, e.target)
});
console.clear();