svg

svgify

A browserify transform for requiring SVG files to embed directly in your code.

Showing:

Popularity

Downloads/wk

40

GitHub Stars

9

Maintenance

Last Commit

8yrs ago

Contributors

0

Package

Dependencies

2

Size (min+gzip)

13.3KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

svgify

A browserify transform for requiring SVG files to embed directly in your code.

The intention is to be able to quickly inline files saved from Illustrator - it's still a bit rough around the edges, but should improve over time.

Installation

npm install svgify

Usage

createElement = require('./file.svg')

Returns a function that will create a new SVG <g> element containing the contents of the SVG file supplied.

createElement([xOffset[, yOffset]])

Call the function and you'll get an element in return - optionally, you can pass x/y transform variables to offset the contents of the group.

var circle = require('./circle.svg')
var svg = document.createElement('svg')

// Assuming the circle is 64x64,
// this makes the center of the circle
// the origin.
var el = circle(-32, -32)

svg.appendChild(circle)
document.body.appendChild(svg)

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100