JSFiddle - React, Tailwind, and code Playground
by Nasuvaika
HTML
<label id="forcheckbox" for="checkbox">
<div id="popup"></div>
<input id="checkbox" type="checkbox" />
</label>
CSS
* {
margin: 0;
padding: 0;
}
#forcheckbox {
position: relative;
}
#forcheckbox::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 20px;
height: 20px;
border: 1px solid #cc0000;
border-radius: 100%;
cursor: pointer;
}
#popup {
position: absolute;
top: 6px;
left: 6px;
width: 10px;
height: 10px;
background: #cc0000;
border-radius: 100%;
cursor: pointer;
opacity: 0;
transition: 0.2s;
}
#checkbox {
opacity: 0;
}
JavaScript
$(document).ready(function() {
$('#checkbox').click(function() {
if ($(this).is(':checked')) {
$('#popup').css('opacity', '1');
console.log('checked');
} else {
$('#popup').css('opacity', '0');
console.log('unchecked');
}
});
});