How to add an SVG icon set to your project
There are four common ways to put SVG icons on a page. They differ in whether the icon can take your text colour, how many requests they make, and how they work with frameworks.
| Method | Takes text colour | Best for |
|---|---|---|
| Inline SVG | Yes | A few icons, full control |
<img> | No | Static, single-colour pages |
Sprite + <use> | Yes | Many icons on plain HTML sites |
| Components | Yes | React and similar frameworks |
1. Inline SVG
Paste the file's contents straight into your HTML. Shapes drawn in currentColor take the surrounding text colour.
<button aria-label="Search">
<svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" aria-hidden="true">…</svg>
</button>
2. An image tag
<img src="icons/search.svg" alt="Search" width="24" height="24">
Simple and cacheable, but an image can't see your CSS, so currentColor draws black. Avoid it for dark mode or coloured buttons.
3. A sprite with <use>
<svg width="24" height="24" aria-hidden="true"><use href="sprite.svg#icon-search"/></svg>
One file holds every icon, and each use takes your text colour. The sprite must come from the same site as the page; browsers block cross-origin <use> and files opened from disk.
4. Components
import { SearchIcon } from './icons/react/icons.js';
<SearchIcon size={20} />
The most convenient option in a framework: sizes, colours and labels become props. See SVG icons for React.
Accessibility, whichever you choose
- An icon next to visible text is decoration: hide it with
aria-hidden="true". - An icon-only button needs a name: put
aria-labelon the button, not the icon. - An icon that stands alone and carries meaning needs
role="img"and a label. - Animated icons must stop for people who set reduced motion.
Every Inkicon pack follows these rules and includes all four formats, with a README showing each.