The best way to add icons to a project is to use a dedicated icon library or design software.

Best way to manage icons in an Angular project, here's a breakdown of the top approaches — with their pros and when to use them:
✅ Option 1: Inline SVGs (Best for styling and accessibility)
✅ How:
<a href="https://twitter.com/yourcompany" target="_blank" aria-label="Twitter">
<svg class="icon icon-twitter" aria-hidden="true">
<use xlink:href="assets/icons/sprite.svg#twitter"></use>
</svg>
</a>
Pros:
Fully stylable with CSS (
fill
,stroke
,hover
, etc.)Better performance when using SVG sprites (one file, multiple icons)
Accessible with
aria-*
How to create sprite (optional):
Use a tool like SVGOMG or svg-sprite-generator to build a sprite file.
✅ Option 2: Use Angular Material Icons (if you're already using Angular Material)
✅ How:
<mat-icon fontSet="fa-brands" fontIcon="fa-twitter"></mat-icon>
With FontAwesome
or custom fonts.
Pros:
Easy integration with Angular Material
Tons of available icons
Dynamic theming possible
Setup:
npm install @fortawesome/fontawesome-free
Add to angular.json
:
"styles": [
"node_modules/@fortawesome/fontawesome-free/css/all.min.css",
"src/styles.css"
]
✅ Option 3: Use SVG Icon Registry (MatIconRegistry
) for Angular
This is more advanced and Angular-native.
Example:
In app.module.ts
:
import { MatIconRegistry } from '@angular/material/icon';
import { DomSanitizer } from '@angular/platform-browser';
constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {
iconRegistry.addSvgIcon(
'twitter',
sanitizer.bypassSecurityTrustResourceUrl('assets/icons/twitter.svg')
);
}
And in template:
<mat-icon svgIcon="twitter"></mat-icon>
✅ Option 4: Continue Using <img src="...">
(Simple and safe)
Your current approach is:
<img src="assets/icons/twitter.svg" alt="Twitter" />
Pros:
Very simple
No setup required
Works with asset pipeline
Cons:
Less control over styles (can’t
fill: red
directly)Slightly heavier on DOM than inline SVG
Option 5:
<div class="footer-socials">
<a href="https://twitter.com/yourcompany" target="_blank" aria-label="Twitter">
<img src="assets/icons/twitter.svg" alt="Twitter" />
</a>
<a href="https://linkedin.com/company/yourcompany" target="_blank" aria-label="LinkedIn">
<img src="assets/icons/linkedin.svg" alt="LinkedIn" />
</a>
<a href="https://github.com/yourcompany" target="_blank" aria-label="GitHub">
<img src="assets/icons/github.svg" alt="GitHub" />
</a>
</div>
✨ Recommended Best Practice
If you want full control, performance, and flexibility:
✅ Use inline SVGs or an SVG sprite system
✅ Optionally register them via Angular’sMatIconRegistry
if using Angular Material
Example (your current HTML improved with inline SVG for styling):
<a href="https://twitter.com/yourcompany" target="_blank" aria-label="Twitter">
<svg class="icon icon-twitter">
<use xlink:href="assets/icons/sprite.svg#twitter"></use>
</svg>
</a>
And in CSS:
.icon {
width: 24px;
height: 24px;
fill: currentColor;
}
a:hover .icon {
color: #1DA1F2; /* Twitter blue */
}
Subscribe to my newsletter
Read articles from sunny g directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

sunny g
sunny g
I am a full-stack developer with 8+ years of experience, passionate about the JavaScript ecosystem. I have a bachelor's degree in computer science. I am most skilled and passionate about Angular and React. I am able to provide meaningful contributions to the design, installation, testing, and maintenance of any type of software system. I like to challenge myself in new roles. I have built and successfully delivered applications in multiple domains. In my free time, I like to write blogs related to software development. I have the pleasure of working on exciting projects across industries. The applications that I developed were scalable, deployable, and maintainable. I have a vision of providing cutting-edge web solutions and services to enterprises. Developed zero-to-one products.