gistlib
index.tsxconst svgCode = ` <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"> <rect width="100" height="100" style="fill:rgb(0,0,255);stroke-width:1;stroke:rgb(0,0,0)" /> </svg> `; // Copy to clipboard function copyToClipboard(text) { const el = document.createElement("textarea"); el.value = text; document.body.appendChild(el); el.select(); document.execCommand("copy"); document.body.removeChild(el); } copyToClipboard(svgCode); console.log("SVG code has been copied to clipboard"); 508 chars19 lines
const svgCode = ` <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"> <rect width="100" height="100" style="fill:rgb(0,0,255);stroke-width:1;stroke:rgb(0,0,0)" /> </svg> `; // Copy to clipboard function copyToClipboard(text) { const el = document.createElement("textarea"); el.value = text; document.body.appendChild(el); el.select(); document.execCommand("copy"); document.body.removeChild(el); } copyToClipboard(svgCode); console.log("SVG code has been copied to clipboard");
Make sure to adjust the SVG code within the svgCode variable to generate the desired SVG image.
svgCode
gistlibby LogSnag