Choosing an icon system: inline, sprite, symbol, font or data URI
An interface icon set is a small design system, and the delivery format decides how it behaves under caching, theming and accessibility. There are five practical options: inline SVG in the markup, an external sprite referenced with <use>, a symbol sprite embedded in the document, an icon font, and a data URI in CSS. Each has a different cost profile and a different failure mode.
| Approach | Requests | Theming | Main notes |
|---|---|---|---|
| Inline SVG | 0 extra | currentColor works | Duplicated markup, full a11y control |
| External sprite + use | 1 (cacheable) | currentColor works in modern browsers | Requires same-origin or CORS |
| Inline symbol sprite | 0 extra | currentColor works | One copy in the document, hidden defs |
| Icon font | 1 font file | Colour only, no stroke control | Glyph rendering and a11y problems |
| CSS data URI | 0 extra | Mask needed for colour | Good for tiny repeated icons |
The inline component is the default in React
In a React or Vue application the build already produces a bundle, so an icon component adds no request and no runtime cost beyond the markup. It gives the clearest accessibility control, because the component can render aria-hidden by default and accept a title prop. The cost is duplication: the same path data appears in every bundle that imports the icon, which is why a large set should be code-split or tree-shaken.
Name the component after the meaning, not the shape. TrashIcon is better than BinIcon when the action is delete; it lets the drawing change without renaming every import. Keep a single source of truth for the path data, usually an icons directory of .svg files, and generate components from it.
Sprites for many icons
A sprite collects symbols into one file. <symbol id="icon-search" viewBox="0 0 24 24"> holds the drawing, and <use href="sprite.svg#icon-search"> renders it. The page downloads one file that caches well, and every icon inherits currentColor. The catch is that external use requires the sprite to be same-origin or served with CORS headers, and some older browsers refuse external references entirely.
Embedding the sprite in the document avoids the CORS issue at the cost of putting every icon in the HTML. That is fine for a small set and wasteful for a large one. Either way, hide the sprite container with display: none on a wrapping svg or place it at the end of the body with zero size, and keep the symbols free of ids that could collide with page ids.
Consistency rules that keep a set usable
Draw every icon on the same grid with the same stroke width and the same corner radius. Round the line caps and joins unless the design calls for square corners. Align optical centres rather than mathematical centres: a play triangle looks off-centre when centred by bounding box. Give every icon the same viewBox so a size prop means the same thing across the set.
Finally, decide the decorative default once. Most icons sit next to a text label and should be hidden from assistive technology; the few that carry meaning get a name. A consistent rule prevents the situation where half the set is announced and half is silent, which is worse than either choice applied everywhere.
Sources
Questions
Should icons be a sprite or individual files?
A sprite wins when a page uses many icons: one request, one cache entry and no repeated markup. Individual files win when icons are few, change often, or need per-icon caching. Inline components win in a React app where the build already bundles the markup. Measure the set, not the preference.
Why not use an icon font?
Icon fonts render glyphs as text, so they inherit font smoothing, can be affected by text-size adjustment, fail when the font is blocked, and are read as characters by screen readers. SVG gives you colour, stroke width and accessibility control that a font does not.
How do I recolour an SVG icon?
Use currentColor in the fill or stroke of the paths and set the colour on the parent. An inline SVG inherits it. A sprite referenced with use also inherits it in modern browsers. A data URI in a background image does not, so use a CSS mask for that case.
Optimize each icon in the set once and keep the source files next to the generated sprite.
Open the optimizerWritten against the W3C SVG specifications, MDN and the React and WCAG documentation; every sample in the examples can be pasted into the optimizer linked above.
Back to the guides