0.2.2 • Published 6 years ago

@iconfu/svg-sprite-inject v0.2.2

Weekly downloads
338
License
MIT
Repository
github
Last release
6 years ago

SVGSpriteInject

What does is do

SVGSpriteInject puts an SVG sprite inline in the document body of an HTML document.

Why should I use it?

In order to apply CSS styles to SVG sprite images, the SVG sprite has to be inline in the DOM. With the SVG sprite injector you can keep your SVGs as individual files, but you can still style the SVG with CSS.

Install

Manually

Include the SvgInject javascript file in your HTML document

<head>
  ...
  <script src="svg-sprite-inject.min.js"></script>
  ...
</head>

plain version: svg-sprite-inject.js

minified version: svg-sprite-inject.min.js

npm

$ npm install @iconfu/svg-sprite-inject

Yarn

$ yarn add @iconfu/svg-sprite-inject

Usage

Call SvgSpriteInject(pathToSvg) to inject an SVG sprite.

SvgSpriteInject('path/to/svg-sprite.svg')

You can display SVGs included in the SVG sprite anywhere in your document.

<svg width="128" height="128"><use xlink:href="#svg-sprite-image-name"></use></svg>

Advanced Topics

How does it work?

The SVG sprite injector loads the SVG sprite and puts it inline into the HTML body tag.

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago