JSFiddle - React, Tailwind, and code Playground
HTML
<input type="checkbox" id="choice1">
<label for="choice1">Choice 1</label>
<input type="checkbox" id="choice2">
<label for="choice1">Choice 2</label>
<input type="checkbox" id="choice3">
<label for="choice1">Choice 3</label>
JavaScript
var checkboxes = [
document.getElementById('choice1'),
document.getElementById('choice2'),
document.getElementById('choice3'),
];
var uncheckAll = function () {
checkboxes.forEach(function (checkbox) {
checkbox.checked = false;
});
}
checkboxes.forEach(function (checkbox) {
checkbox.addEventListener('click', function () {
uncheckAll();
this.checked = true;
});
});