tigt / mini-svg-data-uri

Small, efficient encoding of SVG data URIs for CSS, HTML, etc.
https://npm.runkit.com/mini-svg-data-uri
MIT License
309 stars 16 forks source link

Going the other direction #21

Closed alexgleason closed 3 years ago

alexgleason commented 3 years ago

Hi, I want to use this package to inline svgs with Webpack asset modules.

When I render them, though, I want to take the data URI and convert it back to plain SVG data so I can dangerouslySetInnerHTML. This way I can control things like the fill color with CSS.

Any suggestions on how to achieve that?

alexgleason commented 3 years ago

Nvm, react-inlinesvg does this for me:

<InlineSVG src={src} />

src can be literally anything, including a remote URL or a data URI. Very nice. Thanks for this nice script.

tigt commented 3 years ago

Nice to see you found a solution. If you or anyone else viewing this issue are curious how to do it vanilla, I’m pretty sure reversing the output is doable through decodeURIComponent().