JSFiddle - React, Tailwind, and code Playground
HTML
<div id="teste">Um <strong>texto</strong> <em>qualquer</em>.</div>
<button>Copiar</button>
JavaScript
document.querySelector("button").onclick = function() {
var divACopiar = document.querySelector("#teste");
var range = document.createRange();
range.selectNode(divACopiar);
window.getSelection().addRange(range);
document.execCommand("copy");
};