React Component to load and inline SVG images, allowing you to target and style SVGs using CSS.
- Easy to use, just add
InlineSVGcomponents - Loads SVGs automatically using a
XMLHttpRequest - Loads each SVG exactly once, and caches them for repeated use
- Can preload SVGs in advance using
InlineSVG.cache
$ npm i --save jacobmarshall-react-inline-svg
Include the component:
<scriptsrc="https://unpkg.com/jacobmarshall-react-inline-svg@2.0/dist/react-inline-svg.js"></script>Or...
importInlineSVGfrom'jacobmarshall-react-inline-svg';Render an inline SVG:
<InlineSVGsrc="/path/to/your.svg"className="css-class" />InlineSVG.cache.load("/path/to/your.svg");To re-build this after making changes in src, simply run:
$ gulp