svg-sprite

github.com ↗

Compile SVG drawings into sprites and associated stylesheet output.

SI Score
80/100
Pricing
Open Source AI reading, not confirmed
Free plan
Yes AI reading, not confirmed
Sign-up required
Not required AI reading, not confirmed

Ask SI about svg-sprite

Answers use saved listing facts and recorded sources.
Homepage screenshot
Screenshot of the svg-sprite homepage

What it does

svg-sprite is a Node.js tool for optimizing SVG inputs and compiling them into several sprite formats. It supports configurable shape naming, spacing and stylesheet generation, with an API, command-line interface and build-tool wrappers. The software uses the MIT licence.

Choose the sprite mode around the consuming markup. A CSS background workflow and an inline symbol workflow need different generated output, even when both begin with the same SVGs. svg-sprite can produce CSS, view, defs, symbol and stack modes from one input set, with CSS, Sass, Less or Stylus templates.

For the Node.js API, create an SVGSpriter with a configuration, add the SVG files, then compile and write the returned resources. The library leaves filesystem reading and writing to your code; its command-line interface and Grunt or Gulp wrappers offer other routes. Configuration controls shape IDs, padding, dimensions, optimization and output paths.

When producing a preprocessor stylesheet, point the destination at the eventual CSS location so relative sprite URLs resolve correctly. The MIT-licensed tool also supports YAML metadata for SVG titles and descriptions. Its listed optimization limitation is that IDs are not minified when an input contains style or script elements.

Strengths

  • One input set can produce several sprite modes.
  • Templates support CSS and major stylesheet preprocessors.
  • Configuration includes shape IDs, padding and accessibility metadata.

Watch out for

  • The low-level API leaves filesystem input and output to the caller.
  • Relative sprite URLs depend on the final CSS output location.

Best for

  • Developers maintaining SVG icon build pipelines

Sources