svg-style-inliner

Inlines styles for all elements in an SVG tree. Useful for creating SVG screenshots with libs like html2canvas.

Usage no npm install needed!

<script type="module">
  import svgStyleInliner from 'https://cdn.skypack.dev/svg-style-inliner';
</script>

README

svg-style-inliner

A pure JavaScript utility to inline styles of all elements in an SVG. Useful to get accurate screenshots of SVGs with libs like html2canvas when using CSS for styling.

This code was straight ripped from the NYT's excellent svg-crowbar.

Use

import inliner from 'svg-style-inliner';

inliner(document.getElementById('your-svg'));