Skip to content
ToolShedby Wasim Shaikh

mat-icon Font to SVG Migration Helper

Move Angular Material mat-icon from the icon font to SVG: rewrites templates to svgIcon, downloads only the Material Symbols you use, and writes the MatIconRegistry code.

How to serve the SVGs
Material Symbols style

With ms, icons become svgIcon="ms:home", so they never clash with your own SVG icons.

How to Switch mat-icon From the Font to SVG

  1. Paste a template. Paste a component template or a .ts file with an inline template, or upload one. Ligatures, fontIcon and {{ interpolations }} are all found.
  2. Choose how to serve icons. A single sprite for most apps, one file per icon for very large sets, or icons inlined in the bundle for SSR and tests.
  3. Match your style. Pick Outlined, Rounded or Sharp, plus fill and weight. A fontSet in your template selects the style for you.
  4. Download and register. Download only the icons you use, paste the app.config.ts code, and replace the template with the rewritten one.
  5. Remove the font. Delete the icon font <link>, then repeat for the next template.

Icon Font vs SVG Icons in Angular Material

 Icon font (ligatures)SVG with MatIconRegistry
First loadThe whole Material Symbols font, which is large because it holds every iconOnly the icons you use, often a few KB in total
Flash before loadThe icon name shows as text (e.g. "home") until the font arrivesNo text flash; the icon appears or the space stays empty
Ad blockers and offlineBreaks if fonts.googleapis.com is blockedServed from your own domain
Colour and sizecolor and font-sizeSame: currentColor and font-size still work with mat-icon
Variable axes (fill, weight)Change at runtime with font-variation-settingsFixed per file; download the variant you need
<!-- Before: icon font -->
<mat-icon>home</mat-icon>
<mat-icon fontIcon="settings"></mat-icon>

<!-- After: SVG -->
<mat-icon svgIcon="home"></mat-icon>
<mat-icon svgIcon="settings"></mat-icon>

Looking up an icon name? Search all Material Symbols in the mat-icon finder. For your own SVGs, the SVG to Angular component converter makes a standalone component, and the SVG Optimizer shrinks the files first. Planning a version upgrade too? See the Angular tools.

Frequently Asked Questions

Why move mat-icon from the font to SVG?
The icon font downloads every icon even if you use ten, shows the ligature text (like "home") until it loads, and fails when Google Fonts is blocked. SVG icons ship only what you use from your own domain.
Do I need to change my CSS?
Usually not. mat-icon sizes SVG icons to 24px like the font, and fill follows currentColor, so color rules keep working. If you resized icons with font-size, also set width and height on mat-icon, because the SVG fills the element rather than following the font size.
Which serving option should I pick?
A sprite file suits most apps: one cached request for all icons. One file per icon, with addSvgIconResolver, suits apps that use hundreds of icons but few per page. Inline literals avoid HTTP entirely, which helps server-side rendering, unit tests and libraries.
What about icons set from a variable, like {{ item.icon }}?
They are rewritten to [svgIcon]="item.icon". The registry only knows registered names, so type every value the variable can take into the extra names box and they are bundled too.
Does this work with the legacy Material Icons font?
Yes, for names that also exist in Material Symbols, which is nearly all of them. Names that only exist in the old font are highlighted, so you can pick a replacement in the Material icon finder.
Which Angular versions are supported?
The registry methods have existed since Angular Material 11. The generated config uses provideAppInitializer, added in Angular 19. On older versions, use APP_INITIALIZER with a factory, or call the registry in your root component constructor.
Is my code uploaded?
No. The template is scanned in your browser. The only network requests are for the icon SVGs themselves, from Google’s fonts.gstatic.com.

Sources & Standards

Last reviewed .

Related Tools