JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.5.0-beta4/html2canvas.min.js"></script>

<iframe id="frame"></iframe>

JavaScript

frame.onload = ()=>{
  html2canvas(frame.contentDocument.documentElement).then((canvas)=>{
    document.body.appendChild(canvas);
  });
  };
frame.src = 'data:text/html,' + encodeURIComponent('<html><body><div style="color:red">Hello world</div></body></html>');