JSFiddle - React, Tailwind, and code Playground
HTML
<p>Some lorem ipsum text here. Lorem ipsum lorem ipsum lorem ipsum lorem ipsum ...</p>
<textarea>Some text here too</textarea>
<button onclick="clearSelection()">Clear selection</button>
JavaScript
function clearSelection() {
//window.getSelection().removeAllRanges();
}