Guides
How to Use SVG Icons: A Practical Guide for Modern Web Apps
How to use SVG icons in modern web apps: inline SVG, SVG sprites, icon fonts and components compared, plus sizing, colouring with currentColor and accessibility basics.
Learning how to use SVG icons properly is a one-time investment that pays off on every project: crisp rendering at any size, full CSS control, and no extra image requests. This guide covers the four delivery methods, when each one wins, and the details teams usually get wrong.
Start with the icon set, not the delivery method
Most icon problems are set problems, not technique problems. Teams grab glyphs from three different libraries, discover the stroke widths clash, patch sizes icon by icon, and end up with a toolbar that looks subtly wrong everywhere. Before you write a line of markup, pick one primary set whose drawing style matches your product: consistent stroke weight, consistent corner radius, and a consistent grid, usually 24 by 24. Every method in this guide works better when the underlying artwork is coherent.
Evaluate a candidate set on coverage, licence and maintenance, in that order. Coverage means the set actually contains the glyphs your roadmap needs, including unglamorous ones like sort, filter, export and empty-state illustrations. Licence means the terms allow commercial use and modification without per-icon attribution gymnastics. Maintenance means the set is still releasing; an abandoned set freezes your product in the year it stopped. You can compare all of these side by side in the library directory before committing.
- Stroke or fill, not both: mixing an outlined set with a filled set in one interface reads as two products. Pick one visual language per surface.
- Grid discipline: sets drawn on a 24 grid with 2px padding scale predictably. Sets with mixed viewBoxes need per-icon size hacks.
- Name coverage: search the set for your ten most-needed actions. If three are missing, the set will fight you for years.
- Licence clarity: MIT and Apache sets are the safest defaults for commercial work. Keep the licence file with your vendored copy.
Method 1: inline SVG (the default for apps)
Paste the SVG markup where the icon belongs. It inherits colour from CSS, can be styled per-instance, and needs no network request. In component frameworks this is what icon packages do under the hood. Keep the viewBox, drop fixed width and height attributes, and control size with CSS or utility classes.
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" class="h-5 w-5" aria-hidden="true">
<path d="M21 21l-4.3-4.3" />
<circle cx="11" cy="11" r="7" />
</svg>What to strip before you paste inline SVG
Raw exports from design tools carry baggage that inline SVG does not need: XML declarations, editor metadata, title elements stuffed with layer names, and width and height attributes that fight your CSS. Before pasting, remove the fixed dimensions, keep the viewBox exactly as drawn, and delete comments and unused defs. If the source uses hard-coded fill colours on every path, replace them with currentColor on the paths you want themed, or the icon will ignore your colour system entirely.
- Remove width and height attributes; size with a class or the width and height props of your icon component instead.
- Keep viewBox untouched. Cropping or rounding it shifts the drawing and breaks alignment with sibling icons.
- Delete ids inside pasted icons, or namespace them. Duplicate ids across inline SVGs are invalid HTML and gradients or masks will reference the first copy only.
- Collapse groups that exist only because of the editor's layer panel; they add bytes and confuse nobody but you, later.
Inline SVG, step by step
The reliable routine is always the same. First, copy the icon markup from your set or export it from your design tool. Second, clean it as described above. Third, decide whether it is decorative or meaningful, and add aria-hidden or an accessible name accordingly, a decision our accessibility guide covers in depth. Fourth, drop it into a wrapper with a fixed size class so layout never depends on the icon loading. Fifth, test it at 16, 20 and 24 pixels, in light and dark mode, and at 200 percent zoom. Icons that survive that pass rarely cause trouble again.
Method 2: SVG sprites for static sites
A sprite defines each icon once as a symbol and references it with use elements across the page. It suits multi-page sites without a build step: one cached file, tiny HTML references, and CSS colouring still works when the symbol uses currentColor. The trade-off is weaker per-icon styling and awkward external-file behaviour in some older browsers.
Building a sprite, step by step
A sprite file is an SVG document whose children are symbol elements, each with its own viewBox and a unique id. You build it by taking every icon you use, wrapping its inner paths in a symbol, and concatenating the results, a job the SVG sprite generator does from a folder of files in seconds. Reference an icon anywhere with an svg element whose use child points at the symbol id, and style the svg element itself for size and colour.
Two sprite decisions matter. The first is inline versus external: inlining the sprite at the top of the body makes references bulletproof and costs one copy per page, while an external sprite file caches across pages but historically had quirks when referenced cross-file in some browsers. The second is theming: symbols that use currentColor internally theme beautifully; symbols with baked-in multi-colour artwork do not, so keep brand logos and colourful spot illustrations out of the sprite and inline them where they live.
- Give every symbol a stable, semantic id such as icon-search or icon-arrow-right; renaming ids later breaks every reference silently.
- Put the sprite include as early in the body as your stack allows, so use references never render before their definitions arrive.
- Version the external sprite file name when icons change, or long-lived caches will serve last month's glyphs.
- Do not sprite icons used exactly once on one page; inline those and keep the sprite for genuinely shared glyphs.
Method 3: icon components and packages
In React, Vue and other frameworks, install a package (or copy components) so icons behave like the rest of your UI code: typed props, tree-shaking and theme-aware colour. Our framework guides for React, Vue 3, Astro and Next.js cover the specifics.
Design your icon component API once
If you wrap icons in your own component, its props decide whether the system stays clean or decays into per-call-site overrides. A good wrapper exposes size as a small set of tokens rather than raw numbers, accepts a className or style for colour through currentColor, and forwards accessibility props without inventing its own. Resist the temptation to accept a colour prop that injects inline styles everywhere; colour belongs to CSS context, and a component that hard-codes it will fight every theme you ship later.
- size: accept token values like sm, md and lg mapped to 16, 20 and 24 pixels, so a future density change is one edit.
- strokeWidth: expose it only if your set supports it; a global default keeps buttons and menus visually consistent.
- title and decorative flags: let the wrapper accept either a title for meaningful icons or a decorative flag that applies aria-hidden and focusable false together, so call sites cannot set one and forget the other.
- No default colour: inherit. The moment a wrapper paints icons a brand colour by default, disabled and error states start lying.
When you copy icons as JSX from a library or a tool such as the SVG to JSX converter, run the output through that wrapper rather than pasting raw svg elements across the codebase. Raw pastes work on day one and become unrefactorable by month three, because nothing central owns size, stroke or accessibility behaviour. Teams that centralise early can restyle every icon in the product by editing one file.
Method 4: icon fonts (mostly legacy)
Icon fonts render icons as text glyphs. They were practical in 2013; today they blur on some displays, flash while loading, break when the font fails, and fight screen readers. Migrate away when you can: the Font Awesome alternatives roundup lists modern SVG sets that cover the same ground for free.
Migrating off an icon font without a big-bang rewrite
Legacy projects rarely get a freeze for icon work, so migrate incrementally. Start by inventorying the font classes actually rendered, not the ones defined; most fonts ship hundreds of glyphs a product never uses. Map each used class to its SVG equivalent in your chosen set, and note the handful with no match, because those drive custom drawing work. Then swap component by component, keeping the font loaded until the last reference is gone. The visual diff per swap should be near zero; if a replacement glyph looks noticeably different in weight, your set choice, not the migration, is the problem.
- Screenshot key screens before and after each batch; icon regressions are subtle and screenshots catch what memory misses.
- Watch text metrics: font glyphs carried line-height behaviour that SVG does not, so expect small alignment fixes in dense toolbars.
- Delete the font files and the fallback CSS only after a full crawl shows zero remaining class references.
- Keep a short mapping note in the repo; the next migration, or a new hire, will thank you for it.
Sizing, colour and alignment rules
- Size icons on the same scale as your type: 16px beside body text, 20px in toolbars, 24px for standalone actions.
- Colour with currentColor so icons follow text colour, hover states and dark mode automatically.
- Align to the text baseline using inline-flex or vertical-align, and give icon buttons a minimum 40px touch target on mobile.
- Mark decorative icons aria-hidden, and give meaningful icon-only buttons an accessible name.
Troubleshooting: the six mistakes everyone makes once
- The icon renders as a giant blob. The viewBox was stripped or the CSS size class never applied. Restore the viewBox and give the svg element explicit dimensions; an unsized inline SVG defaults to the full width of its container.
- The icon ignores your colour. Somewhere a fill or stroke attribute hard-codes a hex value and beats inheritance. Remove it, or set it to currentColor, at the path level and the svg level.
- Icons sit too high or too low next to text. The svg is an inline element aligning to the baseline with descender space below. Wrap icon and label in an inline-flex container with centred alignment instead of nudging with margins.
- One icon looks heavier than its neighbours. It came from a different set, or its stroke width differs. Match stroke width first; if the set differs, replace the icon, not the CSS.
- Gradients and masks render on the wrong icon. Duplicate internal ids across inline SVGs collide. Namespace ids per icon, or avoid id-based fills in shared glyphs entirely.
- The icon is blurry at small sizes. The artwork was drawn for 24 pixels and is being shown at 12, where its details collapse. Choose icons designed with a small-size variant, or accept a simpler glyph at tiny sizes.
Worked example: one icon, three production contexts
Take a single search icon through a real page. In the header search button it is decorative, because the button also carries a visible label, so it gets aria-hidden and a 20 pixel size. In the mobile toolbar the same glyph stands alone, so the button gets an accessible name and a 44 pixel touch target while the glyph stays 20 pixels; size and target are separate decisions. In an empty-state illustration the glyph appears at 48 pixels inside a tinted circle, purely decorative, with the heading below carrying the meaning. Same file, three contexts, three different treatments: that judgement, applied consistently, is most of what using SVG icons well means.
Notice what did not change across those contexts: the artwork, the stroke, the viewBox and the colour mechanism. Consistency lives in the source; flexibility lives in the wrapper and the CSS. When a design asks for a one-off icon that breaks the set's rules, the cheapest correct answer is usually a different glyph from the same set, not a custom drawing. Custom icons earn their cost only for brand marks and genuinely novel concepts.
That is the whole craft: pick one consistent set from the 239 libraries on IconVault, deliver it as components or inline SVG, and let CSS do the theming. Everything else is refinement.
Organising icons inside a design system
Past a few hundred icons, the delivery method stops being the hard part; governance is. Name icons by concept, not by appearance, so search becomes predictable: a glyph called arrow-right survives a redesign, while one called chevron-thin-blue does not. Keep a single source folder or package that design and engineering both pull from, and treat icon additions like dependency additions, with a quick review for duplicates, near-duplicates and licence fit. Products routinely discover they ship four different close icons; a named registry with a search-first culture prevents the fifth.
- Aliases for synonyms: register that bin, trash and delete point at one glyph, so people stop drawing variants of the same idea.
- Deprecation over deletion: mark replaced icons deprecated for a release or two; hard deletions break screens nobody has opened in months.
- One review question: does an existing icon already mean this? If yes, the new drawing needs a justification, not just a designer.
- Document state pairs: for every action icon, define its disabled, hover and destructive appearances once, centrally, instead of per screen.
Icons beyond the browser: native apps and documents
The same SVG source usually feeds your native apps and documents, but each target reinterprets it. iOS and Android design systems accept SVG-derived assets through their own pipelines (asset catalogs and vector drawables), and both impose opinions about fills, strokes and unsupported features like masks, so test the conversion rather than trusting it. PDF and print pipelines handle vector icons beautifully as long as fonts inside artwork are converted to outlines. The discipline that makes all of this painless is the same one from the start of this guide: one clean, optimised, viewBox-intact source per icon, owned in one place. Teams that keep that source tidy can publish to any new platform in an afternoon; teams that let exports scatter across design files start every platform launch with an archaeology project.
How each method behaves for performance
Delivery choice is also a loading choice. Inline SVG adds bytes to the HTML document, which is already on the critical path, so the icons paint with the first render and never shift layout; the cost is paid again on every page that repeats them. Sprites and external files pay one cached download and then cost almost nothing per reference, which wins on long sessions and loses slightly on a single cold page view. Icon fonts concentrate everything into one request but block icon rendering on font loading and produce the familiar flash of letters or boxes when the font is slow. Components behave like inline SVG for rendering, with the advantage that bundlers deduplicate and tree-shake them, so a shared icon used forty times is paid for once per bundle.
The practical rule: optimise for your dominant traffic shape. Content sites with many one-page visits should inline or sprite a small, consistent icon set and keep total icon weight low. Applications with long sessions should componentise, because caching and code splitting reward them on every subsequent screen. Either way, measure the icons you actually ship; our performance guide on optimizing SVG icons shows how to audit the bytes and the rendering cost method by method.
Responsive behaviour and display density
Vectors free you from the density bookkeeping raster icons demand, but they do not free you from responsive judgement. On narrow screens the right move is usually fewer icons, not smaller ones: collapse secondary actions into a menu rather than shrinking a toolbar until targets fail touch guidelines. Where an icon's meaning is density-dependent, such as a data table that switches from full actions to a compact overflow menu, swap the arrangement at breakpoints while keeping the same glyphs, so users relearn layout, not vocabulary. And remember zoom: browsers scale vector icons perfectly at 200 and 400 percent, which is precisely why accessibility guidance prefers them over raster images that pixelate exactly when low-vision users enlarge the page.
Licence hygiene before you ship
Technique is only half of using icons properly; the other half is paperwork nobody sees until it matters. Keep the licence text of every set you ship in your repository, record where each set came from and which version you vendored, and recheck terms when you upgrade a set, because licences occasionally change between major versions. Attribution-required sets are fine to use, but only if the attribution actually ships somewhere users and auditors can find, such as a credits page or an about screen. Five minutes of record keeping per set is the difference between a non-event and a legal scramble during due diligence.
How to use SVG icons on websites: a start-to-finish workflow
The workflow matters more than any single technique. How to use SVG icons on websites well starts with a decision most teams skip: one set, one delivery method, one size scale, agreed before the first icon ships. When you learn how to use SVG icons on websites as a workflow rather than a trick, every later choice gets easier, because the set defines the style, the delivery method defines the code, and the size scale defines the layout. Teams that skip this step end up patching icons one screen at a time, which is how a product accumulates four different search glyphs and nobody can say why.
A practical workflow has five steps. First, audit what the product actually needs: list every action, status and navigation item, then check that your chosen set covers them. Second, clean every file with an optimiser, because raw exports carry editor metadata that adds bytes and breaks theming. Third, wire the icons through one component or one sprite so size and colour are owned centrally. Fourth, test the result at small sizes, in dark mode and at 200 percent zoom. Fifth, record the licence of the set in the repository. Follow those five steps and you will find that SVG icons stop being a recurring discussion and become a solved problem, which is exactly what a mature team wants from its SVG icons.
The last workflow habit is the one that saves the most time: treat icon changes like dependency changes. When a designer proposes a new glyph, the review question is whether an existing glyph already means the same thing, and when the set releases a new version, somebody checks the licence and the changelog before upgrading. How to use SVG icons on websites at scale is mostly this discipline, repeated quietly, and teams that practise it rarely have icon emergencies. The same discipline applies to SVG icons in marketing pages, documentation and email-adjacent surfaces, where the temptation to grab a second set is strongest and where consistent SVG icons matter most for brand trust.
Plain HTML: learning the fundamentals without a framework
Plain HTML is still the fastest way to learn the fundamentals. How to use SVG icons on websites without a framework means pasting clean markup where the icon belongs, sizing it with a class, and colouring it with currentColor so it follows the surrounding text. When you learn how to use SVG icons on websites this way, you see exactly what frameworks hide: the viewBox that preserves proportions, the paths that draw the shape, and the attributes that decide whether assistive technology notices the glyph. That visibility is why every framework guide on this site eventually returns to the same markup.
The plain-HTML routine is short. Copy the icon from your set, strip fixed width and height attributes, keep the viewBox, replace hard-coded fills with currentColor where theming matters, and drop the result into a wrapper with a fixed size class. Give decorative icons aria-hidden, and give icon-only buttons an accessible name on the button itself. Developers who master this routine find that SVG icons in any framework feel familiar, because components and sprites are only packaging around the same SVG icons.
- Keep a single folder of cleaned SVG files as the source of truth, and generate sprites or components from it, never the other way around.
- Name files by concept, such as search, download and settings, so any developer can find a glyph without opening a design tool.
- Test the page with styles disabled once: if an icon disappears or explodes without CSS, its markup carries assumptions the stylesheet should own.
How to use SVG icons on websites built with React
In React, icons should behave like any other component. How to use SVG icons on websites built with React starts with a wrapper component that owns size tokens, colour inheritance and accessibility flags, so call sites pass a name and a size and nothing else. When you learn how to use SVG icons on websites through components, the payoff is centralised control: a density change, a stroke change or an accessibility fix becomes one edit instead of a hundred. The SVG to JSX converter produces component-ready markup, but the wrapper is what turns that markup into a system.
Three component rules prevent most decay. First, size is a token, not a number: sm, md and lg map to 16, 20 and 24 pixels, and a future density change is one mapping edit. Second, colour is inherited, never defaulted: the wrapper paints nothing on its own, so disabled, hover and error states stay honest. Third, accessibility is a prop pair, not a memory test: the wrapper accepts either a title for meaningful icons or a decorative flag that applies aria-hidden and focusable false together. Teams that follow these rules discover that SVG icons across a large React codebase stay consistent without a style guide nobody reads, because the SVG icons themselves enforce the guide.
How to use SVG icons on websites in React also means respecting the bundler. Import icons individually from packages that support tree-shaking, and audit the bundle whenever a barrel import sneaks the whole set back in. One careless import can turn a lean icon system into hundreds of kilobytes of unused glyphs, which is a performance failure wearing a developer-experience costume. The performance guide on optimizing SVG icons shows how to measure this precisely.
Inside a design system: icons as inherited defaults
A design system turns icon choices into defaults other teams inherit. How to use SVG icons on websites inside a design system means the system owns the set, the wrapper, the size tokens and the accessibility patterns, while product teams only choose which glyph and which size. When you learn how to use SVG icons on websites at this level, the interesting work moves from markup to governance: who approves a new glyph, how deprecations are announced, and how the system proves that every icon it ships is licensed for commercial use.
Governance starts with a registry. Every icon gets a concept name, a bucket (decorative, functional or informative), and a licence note pointing at its set. New glyph proposals answer one question first: does an existing icon already mean this? Deprecations are announced for a release or two rather than deleted outright, because hard deletions break screens nobody has opened in months. Documented this way, SVG icons become as boring and reliable as the colour tokens beside them, and product teams stop reinventing SVG icons for every feature.
Finding the right set: coverage, licence and maintenance
Set choice is the highest-leverage decision in this entire guide. How to use SVG icons on websites well depends on a set whose coverage matches your roadmap, whose licence allows commercial use, and whose maintenance is alive. When you learn how to use SVG icons on websites from the IconVault directory, you can compare 239 sets side by side, from Lucide with 2,144 icons under ISC to Tabler with 6,462 icons under MIT, Phosphor with 9,198 icons under MIT, and Material Symbols with 24,569 icons under Apache-2.0. The library directory lets you search each set for your ten most-needed actions before committing, which is the single most useful test in this guide.
Coverage beats taste in set selection. A beautiful set missing sort, filter, export and empty-state glyphs will force a second set within months, and two sets in one toolbar read as two products. Check licence terms with equal care: MIT, ISC and Apache-2.0 sets are safe defaults for commercial work, while CC BY sets such as Solar with 8,682 icons require visible attribution that must actually ship. Teams that pick on coverage and licence first find that SVG icons stay consistent for years, while teams that pick on one beautiful hero glyph end up restocking SVG icons every redesign.
Mistakes to avoid: five judgement errors
Most icon bugs are decisions, not typos. How to use SVG icons on websites badly usually means one of five mistakes: mixing two sets in one surface, stripping the viewBox, hard-coding colours that defeat theming, forgetting touch targets on icon-only buttons, or shipping decorative icons without aria-hidden so screen readers narrate a parts list. When you learn how to use SVG icons on websites, memorise this list before you memorise any syntax, because syntax is searchable and these judgement errors are not.
Two of the five mistakes deserve special attention. Mixing sets is the most expensive, because it cannot be fixed with CSS: a heavier glyph beside lighter ones reads as a different product, and the only repair is replacing the glyph. Stripping the viewBox is the most confusing, because the icon renders fine at one size and explodes at every other, which sends developers hunting through stylesheets for a bug that lives in the markup. Avoid both and your SVG icons will look intentional, and intentional-looking SVG icons are what users experience as polish.
A pre-launch checklist for production icons
A checklist beats a review meeting. How to use SVG icons on websites safely before launch means verifying a short list: every icon comes from one set, every file is optimised, every icon-only button has an accessible name and a 40 pixel touch target, every decorative icon is hidden from assistive technology, and every set's licence is recorded in the repository. When you learn how to use SVG icons on websites with this checklist taped to the release process, icon regressions stop reaching production, because the checks are mechanical and the failures are visible.
- Run a visual diff at 16, 20 and 24 pixels, in light and dark mode, and at 200 percent zoom; cramped icon rows are the first thing to break under zoom.
- Search the codebase for duplicate glyph names and near-duplicates; products routinely ship four different close icons without noticing.
- Confirm the sprite or bundle contains only icons the product renders; unused glyphs are dead weight with a maintenance bill.
- Check forced-colors mode once per release; hard-coded fills vanish there, while currentColor icons adapt automatically.
Dark mode and theming: icons that adapt
Theming is where SVG earns its keep. How to use SVG icons on websites that support dark mode means one rule above all: icons inherit colour through currentColor and never carry their own. When you learn how to use SVG icons on websites with this rule, dark mode becomes a colour-token change instead of a second icon library, hover states work for free, and disabled states stop lying about what is clickable. The same rule protects forced-colors mode and high-contrast themes, where baked-in fills disappear against user-chosen backgrounds.
Multi-colour marks are the exception that proves the rule. Brand logos and duotone illustrations sometimes need fixed colours, and the honest approach is to define those colours as CSS variables so a theme can still override them deliberately, rather than scattering hex values through markup. Keep those marks out of the shared icon sprite and out of the icon component: they change on a brand calendar, not a product one, and coupling their releases to the icon system creates coordination cost for no benefit. Handled this way, SVG icons theme cleanly everywhere, and the few SVG icons that must stay fixed are visible, documented exceptions instead of hidden surprises.
How to use SVG icons on websites in navigation, toolbars and data tables
Navigation is where users meet your icon system most. Navigation is where users meet your icon system most, so how to use SVG icons on websites in navigation deserves deliberate choices. When you plan how to use SVG icons on websites for a header or sidebar, keep the set, the size and the stroke identical across every item, because a single heavier glyph in a nav row reads as a selected state that is not selected. Remember that how to use SVG icons on websites in navigation also means labelling: decorative glyphs beside visible labels stay hidden, while standalone glyphs need names on their controls. Teams that treat navigation as the showcase of their SVG icons, and test their SVG icons there first, catch inconsistency before it spreads to the rest of the product.
Toolbars raise the stakes, because actions sit close together and every glyph competes for attention. How to use SVG icons on websites in toolbars means sizing for touch as well as sight: the glyph may be 20 pixels, but the target must be at least 40, and grouped actions need dividers or spacing that survive translation into longer labels. When you practise how to use SVG icons on websites in dense toolbars, test with real labels in your longest supported language, since a toolbar that fits in English can overflow in German and push SVG icons into wrapping or clipping. A toolbar whose SVG icons survive that test will survive almost anything else.
Data tables are the third surface worth a deliberate pass. Status glyphs in a table row must never rely on colour alone, because colour-blind users and greyscale printing erase the distinction; pair the glyph with a shape change or a text status. How to use SVG icons on websites in tables therefore starts with meaning, not decoration, and the same discipline that makes SVG icons accessible also makes them scannable for every sighted user. If you remember one rule for tables, make it this: how to use SVG icons on websites in tables is a labelling problem first and a drawing problem second, and a table that follows it will read clearly in every mode you test.
A final habit ties these surfaces together: review icons in context, not in a gallery. A glyph that looks perfect on a white artboard can vanish on a tinted card, clash with a neighbouring set, or shrink below legibility beside dense text. Open the real screens, at real sizes, with real data, and judge SVG icons there. The gallery is for choosing SVG icons; the product is for judging SVG icons, and teams that keep that distinction ship SVG icons that feel inevitable rather than decorated.
Marketing pages and documentation: where consistency pays
Marketing pages are where a second set sneaks in. Marketing pages are often built by different people than the product, which is how a second icon set sneaks in through a landing page. How to use SVG icons on websites for marketing means sharing the same set, the same wrapper and the same size tokens as the product, so a visitor moving from a landing page into the app never feels a style change. When teams document how to use SVG icons on websites for marketing, the document should name the set, the sizes and the licence in one place, because marketing contractors cannot follow rules they cannot find, and how to use SVG icons on websites for marketing is a question the brand team should answer once, in writing, rather than per campaign. Get this right and the SVG icons on a homepage, a pricing page and a docs site all read as one brand, which is worth more than any single SVG icons choice on any one page.
Documentation has the opposite problem: too many icons, not too few. Every feature page wants illustrative glyphs, and without a rule the docs accumulate decorative icons that add noise for screen-reader users and weight for everyone else. How to use SVG icons on websites for documentation therefore starts with restraint: icons mark actions and warnings, not paragraphs, and every decorative glyph is hidden from assistive technology. A docs site that practises how to use SVG icons on websites for documentation with restraint also loads faster, because its SVG icons stay few and its SVG icons stay optimised, which readers on slow connections notice immediately. And when documentation shows how to use SVG icons on websites for documentation in its own code samples, those samples should use the same wrapper and tokens as the product, so readers copy a pattern that is already correct.
Ownership is the common thread. The common thread is ownership. Somebody, or some team, owns the set, the tokens and the rules, and every surface, product, marketing or docs, draws from that ownership. How to use SVG icons on websites across an organisation is less a technical problem than an ownership problem, and organisations that name an owner stop relitigating icon choices in every review, and how to use SVG icons on websites across an organisation should be reviewed once a year, not once per crisis. If you take one action from this section, let it be that: write down how to use SVG icons on websites in your organisation, name the set, name the sizes, name the licence, and point every new surface at that document. Future you, and every future contractor, will work from SVG icons that match, and matching SVG icons are the quietest form of brand consistency there is.
Frequently asked questions
Should I inline every SVG icon or use a sprite?
Inline the icons that appear above the fold or only once, and sprite the ones repeated across many pages of a static site. In component frameworks, skip both dilemmas and use icon components, which tree-shake and theme like the rest of your code. The deciding factors are repetition, caching and how much per-icon styling you need, not fashion.
Why does my SVG icon show up black no matter what CSS I write?
A hard-coded fill or stroke attribute in the markup is overriding inheritance. Attributes beat inherited CSS colour because the paths never ask for currentColor. Remove the colour attributes or set them to currentColor, then control the icon through the CSS color property on a parent element, which also makes hover and dark-mode states work for free.
What size should SVG icons be in a user interface?
Match the icon to the text it sits beside: 16 pixels next to body copy, 20 pixels in toolbars and buttons, 24 pixels for standalone actions and navigation. Keep the clickable target larger than the glyph, at least 40 pixels on touch devices, and test at 200 percent zoom, where cramped icon rows are the first thing to break.
Can I use SVG icons in email and social images?
Generally no. Several email clients, including older Outlook versions, ignore or mangle SVG, and social platforms require raster images by specification. Export those specific assets as PNG at the exact size needed and keep SVG as the source of truth in your design system, so the raster exports can be regenerated whenever the artwork changes.
How many icon sets should a product use?
One for the interface, full stop. A second set is acceptable only for a clearly separate surface, such as marketing illustrations, and even then the two should never share a toolbar or a button row. Every additional set adds mismatched strokes, extra bytes and licensing surface, and users read the inconsistency as sloppiness even when they cannot name it.
Find the icons from this guide
Search 421,020 free SVG icons from 239 libraries in one place.