JSFiddle - React, Tailwind, and code Playground

HTML

<input type="checkbox"/> Checkbox 1
<input type="checkbox"/> Checkbox 2
<input type="checkbox"/> Checkbox 2
<button onclick="marcarDesmarcarTodos()">marcar / desmarcar todos</button>

JavaScript

var estado = false;
function marcarDesmarcarTodos() {
    var checkboxes = document.querySelectorAll('input[type=checkbox]');
    for (var i = 0; i < checkboxes.length; i++) {
        checkboxes[i].checked = !estado;
    }
    estado = !estado;
}