I want to convert all of my 4 SVGs into one SVG image (with the same size/quality) and use them as a single sprite CSS image on my website.
Is there any way that I can put all of my SVGs into one file and then I can use them as a sprite like when you use jpg or png files? I don’t want to use code methods (using or tags) just need an image like when you want to sprite a jpg file
2
Answers
I’m using a simple way with svg, mainly for icons or sprite
I have a js file of the icons/sprite I need. I’ve a big one and project per project I’m adding svg I need. It’s convenient and very small. That’s the icons json you have at beginning of the snippet (normally in external file).
When I need an icon, I put a class ico and a data attribute icon with the name of the icon wanted.
Each svg have fill and stroke with currentColor which permit to color them from css. You can also manipulate width if needed.
Check the snippet, perhaps not answering exactly your request but can give you some tracks.
If you need SVG icons, go the modern Native JavaScript Web Components JSWC route