Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include material icon library in Angular?

(I refer this link Issue #2662 for that), I add CSS in angular.json and import library instyle.css It gives an error like :

./src/styles.css (./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./src/styles.css)

What is the proper way to install material icon library in the local project in angular?

npm install material-design-icons-iconfont --save

angular.json

"styles": [
  "src/styles.css",
  "../node_modules/material-design-icons/iconfont/material-icons.css",
],

style.css

@import "~material-design-icons-iconfont/dist/material-design-icons";

index.html

<link href="../material-design-icons-iconfont/dist/fonts/" rel="stylesheet">
like image 536
Dharmesh Avatar asked Sep 27 '18 11:09

Dharmesh


3 Answers

First install via npm the material-icon package:

npm install material-icons --save

Then import the CSS library on your Angular project editing the angular.json file:

 "styles": [
        "src/styles.css",
        "node_modules/material-design-icons/iconfont/material-icons.css",
    ]
like image 193
Sandro De Marco Avatar answered Nov 20 '22 12:11

Sandro De Marco


using this link resolved my problem(https://www.npmjs.com/package/material-icons)

npm i material-icons

styles.css

@import '~material-icons/iconfont/material-icons.css';
like image 45
Dharmesh Avatar answered Nov 20 '22 10:11

Dharmesh


Try to post this code in your index.html :

<head>
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  </head>
like image 1
mecab1995 Avatar answered Nov 20 '22 12:11

mecab1995