Angular Material icons not working

前端 未结 14 2125
走了就别回头了
走了就别回头了 2020-12-23 20:27

I\'ve installed Material for angular,

I\'ve imported on my app module MatIconModule (with import { MatIconModule } from \'@angular/material/icon\';)

相关标签:
14条回答
  • 2020-12-23 20:36
    **Add following code to your css**
    
     .material-icons {  
        /* Support for all WebKit browsers. */
        -webkit-font-smoothing: antialiased;
    
        /* Support for Safari and Chrome. */
        text-rendering: optimizeLegibility;
    
        /* Support for Firefox. */
        -moz-osx-font-smoothing: grayscale;
    
        /* Support for IE. */
        font-feature-settings: 'liga';
    }
    
    0 讨论(0)
  • 2020-12-23 20:38

    In my case, the icon name I wrote wasn't associated to any icon.

    You can check the correct names here: https://material.io/tools/icons/?style=baseline

    0 讨论(0)
  • 2020-12-23 20:38

    I ran into the issue of icons not displaying for me. I had followed the steps provided by Basavaraj Bhusani however still not working.

    I found the issue was that in my scss, I had the text-transform: uppercase which was causing the icon to just display the content 'arrow_forward'. I had to change the text-transform: none on the icon specifically otherwise it would not render.

                    .child-item-action {
    
                        text-transform: uppercase;
    
                        &:after {
    
                            font-family: 'Material Icons';
                            content: "arrow_forward";
                            text-transform: none;
                            -webkit-font-feature-settings: 'liga';
    
                        }
    
    0 讨论(0)
  • 2020-12-23 20:43

    You must import MatIconModule and use the following url in index.html

    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    
    0 讨论(0)
  • 2020-12-23 20:43

    Just Add the following to your index.html:

    link href="https://fonts.googleapis.com/icon?family=Material+Icons"  rel="stylesheet"
    
    0 讨论(0)
  • 2020-12-23 20:44

    For Angular 6+:

    1. npm install this: npm install material-design-icons
    2. add the styles to angular.json:

      "styles": [
        "node_modules/material-design-icons/iconfont/material-icons.css"
      ]
      
    0 讨论(0)
提交回复
热议问题