Star on GitHub

Sprite your SVGs

Paste your SVG code below to generate an optimized sprite. Why?

  • Improved Performance: Fewer HTTP requests
  • Styling Flexibility: CSS-stylable icons
  • Smaller JS Bundle: Externalizes icon data

Still not convinced? Read more about it on Ben Adam blog post, Jacob Paris blog post or Kent C. Dodds' Epic Stack documentation

How to use it?

  1. Paste your svg to be optimized and converted to a symbol
  2. Copy the generated code above and paste it in a file called sprite.svg in the assets folder of your project.
  3. Use the svg on your project like this:
    				
    <svg class="w-6 h-6">
    	<use href="/sprite.svg#icon-name" />
    </svg>
    		
    		
  4. Bonus: If you are using a framework you can create a component:
    					
    import React from 'react';
    
    const Icon = ({ name, ...props }) => (
    	<svg {...props}>
    	<use href={`/sprite.svg#${name}`} />
    	</svg>
    );
    
    export default Icon;
    						
    					
    And then use it like this:
    			
    <Icon name="icon-name" className="w-6 h-6" />
    			
    		

Built by José Donato using Sveltekit, TailwindCSS and melt-ui.