JSFiddle - React, Tailwind, and code Playground

HTML

<div>
  <svg viewBox="-4 -4 8 8" id="bg" xmlns="http://www.w3.org/2000/svg">
    <circle r="4" />
  </svg>
</div>

<section></section>

CSS

div {
  width: 4em;
}

section {
  outline: 1px dotted red;
  width: 8em;
  height: 8em;
}

JavaScript

var svg = document.getElementById('bg').outerHTML;
var blob = new Blob([svg], {type: 'image/svg+xml;charset=utf-8'});
var url = URL.createObjectURL(blob);
document.querySelector('section').style.backgroundImage = 'url(' + url + ')';