Socket
Socket
Sign inDemoInstall

svg-symbol-sprite

Package Overview
Dependencies
22
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    svg-symbol-sprite

A script to generate a symbol sprite from SVG files


Version published
Weekly downloads
1.3K
decreased by-41.34%
Maintainers
1
Install size
6.17 MB
Created
Weekly downloads
 

Changelog

Source

1.4.0

14 November 2022

Readme

Source

Github Build Codacy Badge Codebeat Badge CodeFactor Badge DeepScan grade Analytics

SVG Symbol Sprite

Create an SVG symbol sprite from your SVG files.

GitHub stars GitHub forks GitHub watchers GitHub followers

Code stats

GitHub code size in bytes GitHub repo size GitHub language count GitHub top language GitHub last commit

A Node.js CLI tool which creates an optimized SVG symbol sprite out of a folder full of SVG files.

Provides handy defaults so you don't have to waste time.

All available options can be tweaked. You can even supply your own SVGO config.

This tool is heavily inspried by sprite.sh

Installation

npm i svg-symbol-sprite -g

# or

yarn global add svg-symbol-sprite

Options

ArgumentDescriptionDefault value
-i, --inputSpecifies input dir"." (current directory)
-o, --outputSpecifies output file"./sprite.svg"
-v, --viewboxSpecifies viewBox attribute(parsed from each icon)
-p, --prefixSpecifies prefix for id attribute"icon-"
-c, --configAbsolute path to the SVGO config file or "false"-
-a, --attrsAttributes for the SVG element"aria-hidden="true""
-s, --styleInline style for the SVG element"width: 0; height: 0; position: absolute;"
Usage: svg-symbol-sprite [options]

Options:
    -i, --input     Specifies input dir (current dir by default)
    -o, --output    Specifies output file ("./sprite.svg" by default)
    -v, --viewbox   Specifies viewBox attribute (parsed by default)
    -p, --prefix    Specifies prefix for id attribute ("icon-" by default)
    -c, --config    Absolute path to the SVGO config file or "false"
    -a, --attrs     Attributes for the SVG element ('xmlns="http://www.w3.org/2000/svg" aria-hidden="true"' by default)
    -s, --style     Inline style for the SVG element ("width: 0; height: 0; position: absolute;" by default)

Usage as a package.json script

The tool can be also used as a package.json script. You need to add it to the devDependencies of your project's package.json.

{
	"scripts": {
		"svg-sprite": "svg-symbol-sprite -i ./assets/svgs -o ./dist/sprite.svg"
	}
}
npm run svg-sprite

# or

yarn svg-sprite

Usage without installation (with npx)

The tool can be also used without installing it:

npx svg-symbol sprite -i ./assets/svgs -o ./dist/sprite.svg

SVG Optimization

svg-symbol-sprite optimizes the input SVG files using SVGO and an opinionated configuration file. In order to customize the SVGO config, one can do so by using the -c or --config option and an absolute path to the SVGO config file.

If you wish to completely disable the SVGO files optimization, pass "false" to the --config option.

Accessibility

svg-symbol-sprite does not help with SVG icons' accessibility. This is your responsibility as a developer - you should make sure that your SVGs contain relevant title and id attributes.

LICENSE

MIT


Connect with me:


Support and sponsor my work:

Keywords

FAQs

Last updated on 14 Nov 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc