I am using materializecss. But I can't get the icons to work it says the word but doesn't show the icon?
I included the materializecss and the js but still not working...
Anyone know how to fix this?
I am using materializecss. But I can't get the icons to work it says the word but doesn't show the icon?
I included the materializecss and the js but still not working...
Anyone know how to fix this?
you have to include the icons with this link:
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
place this somewhere in your head and it will work!
You can perform the following steps to render the icon -
add this link in your html page - <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
open the browser and you will see that icon has rendered. but we dont want the icon to be rendered using googleapis.
open the console and go to the src of google apis and open the css file, and copy the whole css and add the css into a css file or materialize.min.css.
you will see the font url in the css that you just copied, open that url in the browser and the file of woff2 format will be downloaded.
now just copy the file into the font folder and change the src of the font in the css file to point to this file.
refresh the page, you will see that icon has rendered.
Thanks
If you are going to use icon don't forget to add CDN. If you are not going to use CDN
you have to download icon files and map with your code.
CDN for Material Icons
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
Following tags can be used to indicate material icons.
<i class="material-icons">add</i>
To get more details please refer this official link. Material-icons
Following is a sample working code snippet with few icons.
<!DOCTYPE html>
<html>
<head>
<title>ICON</title>
<!-- include material-icons -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body class="row">
<div class="col s12" >
<i class="material-icons">add</i>
<i class="material-icons">thumb_up</i>
<i class="material-icons">shopping_cart</i>
<i class="material-icons">perm_identity</i>
</div>
</body>
</html>
If anyone else stumbles here, make sure you are not setting the element's font somewhere else that overrides the icon font. Be especially ware of !important
s.
We can also accomplish this by installing npm package...
Step 1 : npm i material-design-icons
Step 2 : Add link inside angular.json file under style tag as :
"styles": [
"node_modules/material-design-icons/iconfont/material-icons.css"
]