JSFiddle - React, Tailwind, and code Playground
HTML
<input type="checkbox" name="block" id="block">
<div id="box">
The box
</div>
JavaScript
var cbs = document.querySelectorAll('input[type=checkbox]');
for(var i = 0; i < cbs.length; i++) {
cbs[i].addEventListener('change', function() {
if(this.checked) {
document.getElementById("box").style.backgroundColor = "red";
} else {
document.getElementById("box").style.backgroundColor = "transparent";
}
});
}