JSFiddle - React, Tailwind, and code Playground
HTML
<div id="output" style="width:200px;height:200px;background:green;"></div>
JavaScript
$(document).click(function (e) {
if (!$(e.target).closest('#output').length) {
$("#output").hide();
}
});