Material icon not rendering properly in my project, i installed properly but even though not showing in browser.
i followed below steps:
npm install material-design-icons
.angular-cli.json
"styles": [
"styles.css",
"../node_modules/material-design-icons/iconfont/material-icons.css"
],
app.module.ts
import {MatSidenavModule, MatToolbarModule, MatIconModule} from '@angular/material';
app.component.html
<mat-toolbar-row>
<span>Second Line</span>
<span class="example-spacer"></span>
<mat-icon class="example-icon">verified_user</mat-icon>
</mat-toolbar-row>
The material icons are available from the git repository which contains the complete set of icons including all the various formats we are making available. The material icon font is the easiest way to incorporate material icons with web projects.
Similar to other Google Web Fonts, the correct CSS will be served to activate the 'Material Icons' font specific to the browser. An additional CSS class will be declared called .material-icons .
The material icon font is the easiest way to incorporate material icons with web projects. We have packaged all the material icons into a single font that takes advantage of the typographic rendering capabilities of modern browsers so that web developers can easily incorporate these icons with only a few lines of code.
If you have overwritten some existing Angular Material styling or any other styling that somehow affects the icon, it may cause an issue. Move the icon code outside of any styling and test. So I just moved it to the child element. Below is part of Angular Material grid.
I had the same issue. Caused because I was importing the material theme before the fonts in my theme.scss.
Should be:
@import url( 'https://fonts.googleapis.com/css?family=Roboto:400,700|Material+Icons');
@import '~@angular/material/theming';
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
make sure this has been added to your index.html.
I had made my own text font !important
had to make the icons more important:
.lato * {
font-family: 'Lato' !important;
}
.mat-icon{
font-family: 'Material Icons' !important;
}
I had the same issue, because I forgot to add the module on NgModule.imports :
@NgModule({
imports: [
MatIconModule
]
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With