Twenty icons are twenty requests, and each one costs the browser more than it weighs. A sprite puts them all in one file as <symbol>, and then each is used with <use href="#icon-arrow">.
While it is at it, leaving the currentColor option on strips the colours from inside, so the CSS that shows them decides: the same icon serves a light button and a dark one without a duplicate.
How to use it
- Drop in all the icons at once.
- Add a prefix if you want the ids not to clash with anything.
- Process: one sprite.svg comes out.
Frequently asked questions
- How do I use it?
- Paste the contents at the top of the <body>, then call each icon with <svg><use href="#its-id"></use></svg>. If you keep it as a separate file, the reference has to be sprite.svg#its-id.
- Where do the ids come from?
- From each file name, lowercased and hyphenated, with the prefix in front. If two files end up with the same name, the second gets a number.
- Why are my icons black?
- Because with currentColor on they inherit the text colour. Set a colour in the CSS of whatever uses them, or untick the option to keep the original colours.
Related tools
Optimise SVGSVGO in the browser: drops editor metadata and rounds paths.
SVG to PNGRasterise at any size, on a transparent or solid background.
SVG to PDFA one-page PDF at the drawing’s real size.
SVG to CSSThe drawing inside a data URI, with no extra request.
Recolour SVGChange a whole set’s colours without opening them one by one.