JSFiddle - React, Tailwind, and code Playground
HTML
<input type='checkbox'/> 1<br/>
<input type='checkbox'/> 2<br/>
<input type='checkbox'/> 3<br/>
<input type='checkbox'/> 4<br/>
JavaScript
$('input[type=checkbox]').change(function(){
if($('input[type=checkbox]:checked').length >= 2){
$('input[type=checkbox]:not(:checked)').attr('disabled', true);
} else{
$('input[type=checkbox]:disabled').attr('disabled', false);
}
});