Google has revamped its Material Design Icons with 4 new preset themes:
Outlined, Rounded, Two-Tone and Sharp, in addition to the regular Filled/Baseline theme:
But, unfortunately, it doesn't say anywhere how to use the new themes.
I've been using it via Google Web Fonts by including the link:
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
And then using the required icon as suggested in the documentation:
<i class="material-icons">account_balance</i>
But it always shows the 'Filled/Baseline' version.
I've tried doing the following to use the Outlined theme instead:
<i class="material-icons">account_balance_outlined</i>
<i class="material-icons material-icons-outlined">account_balance</i>
and, changing the Web Fonts link to:
<link href="https://fonts.googleapis.com/icon?family=Material+Icons&style=outlined" rel="stylesheet">
etc. But it doesn't work.
And there's no point in taking shots in the dark like that.
tl;dr: Has anyone tried using the new themes? Does it even work like the baseline version (inline html tag)? Or, is it only meant to be downloaded as SVG or PNG formats?
This question is related to
icons
material-design
google-material-icons
Setting up the Two-tone color:
As described above you can use the color
css key except for materials Two-tone theme which seems to be glitchy ;-)
A workaround is described in one of several angular material github issue's by using a custom css filter. This custom filter can be generated here.
E.g.:
Html:
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Round|Material+Icons+Two+Tone|Material+Icons+Sharp">
<i class="material-icons-two-tone red">home</i>
css:
.red {
filter: invert(8%) sepia(94%) saturate(4590%) hue-rotate(358deg) brightness(101%) contrast(112%);
}
Attachments:
New themes are probably not (yet?) part of the Material Icons font. Link.
If you already have material-icons working in your web project, just need to update your reference in the html file and the used class for icons:
html reference:
Before
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
After
<link href="https://fonts.googleapis.com/css?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp"
rel="stylesheet" />
material icons class:
After that just check wich className are you using:
Before:
<i className="material-icons">weekend</i>
After:
<i className="material-icons-outlined">weekend</i>
that works for me... Pura vida!
Simply add your themes to the font link separated by a pipe (|
), like this
<link href="https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Outlined" rel="stylesheet">
Then reference the class, like this:
// class="material-icons" or class="material-icons-outlined"
<i class="material-icons">account_balance</i>
<i class="material-icons-outlined">account_balance</i>
This pattern will also work with Angular Material:
<mat-icon>account_balance</mat-icon>
<mat-icon class="material-icons-outlined">account_balance</mat-icon>
None of the answers so far explains how to download the various variants of that font so that you can serve them from your own website (WWW server).
While this might seem like a minor issue from the technical perspective, it is a big issue from the legal perspective, at least if you intend to present your pages to any EU citizen (or even, if you do that by accident). This is even true for companies which reside in the US (or any country outside the EU).
If anybody is interested why this is, I'll update this answer and give some more details here, but at the moment, I don't want to waste too much space off-topic.
Having said this:
I've downloaded all versions (regular, outlined, rounded, sharp, two-tone) of that font following two very easy steps (it was @Aj334's answer to his own question which put me on the right track) (example: "outlined" variant):
Get the CSS from the Google CDN by directly letting your browser fetch the CSS URL, i.e. copy the following URL into your browser's location bar:
https://fonts.googleapis.com/css?family=Material+Icons+Outlined
This will return a page which looks like this (at least in Firefox 70.0.1 at the time of writing this):
/* fallback */
@font-face {
font-family: 'Material Icons Outlined';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/materialiconsoutlined/v14/gok-H7zzDkdnRel8-DQ6KAXJ69wP1tGnf4ZGhUce.woff2) format('woff2');
}
.material-icons-outlined {
font-family: 'Material Icons Outlined';
font-weight: normal;
font-style: normal;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
-moz-font-feature-settings: 'liga';
-moz-osx-font-smoothing: grayscale;
}
Find the line starting with src:
in the above code, and let your browser fetch the URL contained in that line, i.e. copy the following URL into your browser's location bar:
https://fonts.gstatic.com/s/materialiconsoutlined/v14/gok-H7zzDkdnRel8-DQ6KAXJ69wP1tGnf4ZGhUce.woff2
Now the browser will download that .woff2
file and offer to save it locally (at least, Firefox did).
Two final remarks:
Of course, you can download the other variants of that font using the same method. In the first step, just replace the character sequence Outlined
in the URL by the character sequences Round
(yes, really, although here it's called "Rounded" in the left navigation menu), Sharp
or Two+Tone
, respectively. The result page will look nearly the same each time, but the URL in the src:
line of course is different for each variant.
Finally, in step 1, you even can use that URL:
https://fonts.googleapis.com/css?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp
This will return the CSS for all variants in one page, which then contains five src:
lines, each one with another URL designating where the respective font is located.
Somewhat hilariously, Google has made a font that works correctly in Safari but not in Chrome. Here's the https://codepen.io/anon/pen/zbavza
<i class="material-icons-round red">warning</i>
In reference to https://stackoverflow.com/a/54902967/4740291 and not being able to change the color using css.
As of 27 February 2019, there are CSS fonts for the new Material Icon themes.
However, you have to create CSS classes to use the fonts.
The font families are as follows:
Material Icons Outlined
- Outlined iconsMaterial Icons Two Tone
- Two-tone iconsMaterial Icons Round
- Rounded iconsMaterial Icons Sharp
- Sharp iconsSee the code sample below for an example:
body {_x000D_
font-family: Roboto, sans-serif;_x000D_
}_x000D_
_x000D_
.material-icons-outlined,_x000D_
.material-icons.material-icons--outlined,_x000D_
.material-icons-two-tone,_x000D_
.material-icons.material-icons--two-tone,_x000D_
.material-icons-round,_x000D_
.material-icons.material-icons--round,_x000D_
.material-icons-sharp,_x000D_
.material-icons.material-icons--sharp {_x000D_
font-weight: normal;_x000D_
font-style: normal;_x000D_
font-size: 24px;_x000D_
line-height: 1;_x000D_
letter-spacing: normal;_x000D_
text-transform: none;_x000D_
display: inline-block;_x000D_
white-space: nowrap;_x000D_
word-wrap: normal;_x000D_
direction: ltr;_x000D_
-webkit-font-feature-settings: 'liga';_x000D_
-webkit-font-smoothing: antialiased;_x000D_
}_x000D_
_x000D_
.material-icons-outlined,_x000D_
.material-icons.material-icons--outlined {_x000D_
font-family: 'Material Icons Outlined';_x000D_
}_x000D_
_x000D_
.material-icons-two-tone,_x000D_
.material-icons.material-icons--two-tone {_x000D_
font-family: 'Material Icons Two Tone';_x000D_
}_x000D_
_x000D_
.material-icons-round,_x000D_
.material-icons.material-icons--round {_x000D_
font-family: 'Material Icons Round';_x000D_
}_x000D_
_x000D_
.material-icons-sharp,_x000D_
.material-icons.material-icons--sharp {_x000D_
font-family: 'Material Icons Sharp';_x000D_
}
_x000D_
<!DOCTYPE html>_x000D_
<html>_x000D_
_x000D_
<head>_x000D_
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500|Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp">_x000D_
</head>_x000D_
_x000D_
<body>_x000D_
<section id="original">_x000D_
<h2>Baseline</h2>_x000D_
<i class="material-icons">home</i>_x000D_
<i class="material-icons">assignment</i>_x000D_
</section>_x000D_
<section id="outlined">_x000D_
<h2>Outlined</h2>_x000D_
<i class="material-icons-outlined">home</i>_x000D_
<i class="material-icons material-icons--outlined">assignment</i>_x000D_
</section>_x000D_
<section id="two-tone">_x000D_
<h2>Two tone</h2>_x000D_
<i class="material-icons-two-tone">home</i>_x000D_
<i class="material-icons material-icons--two-tone">assignment</i>_x000D_
</section>_x000D_
<section id="rounded">_x000D_
<h2>Rounded</h2>_x000D_
<i class="material-icons-round">home</i>_x000D_
<i class="material-icons material-icons--round">assignment</i>_x000D_
</section>_x000D_
<section id="sharp">_x000D_
<h2>Sharp</h2>_x000D_
<i class="material-icons-sharp">home</i>_x000D_
<i class="material-icons material-icons--sharp">assignment</i>_x000D_
</section>_x000D_
</body>_x000D_
_x000D_
</html>
_x000D_
Or view it on Codepen
EDIT: As of 10 March 2019, it appears that there are now classes for the new font icons:
body {_x000D_
font-family: Roboto, sans-serif;_x000D_
}
_x000D_
<!DOCTYPE html>_x000D_
<html>_x000D_
_x000D_
<head>_x000D_
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500|Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp">_x000D_
</head>_x000D_
_x000D_
<body>_x000D_
<section id="original">_x000D_
<h2>Baseline</h2>_x000D_
<i class="material-icons">home</i>_x000D_
<i class="material-icons">assignment</i>_x000D_
</section>_x000D_
<section id="outlined">_x000D_
<h2>Outlined</h2>_x000D_
<i class="material-icons-outlined">home</i>_x000D_
<i class="material-icons-outlined">assignment</i>_x000D_
</section>_x000D_
<section id="two-tone">_x000D_
<h2>Two tone</h2>_x000D_
<i class="material-icons-two-tone">home</i>_x000D_
<i class="material-icons-two-tone">assignment</i>_x000D_
</section>_x000D_
<section id="rounded">_x000D_
<h2>Rounded</h2>_x000D_
<i class="material-icons-round">home</i>_x000D_
<i class="material-icons-round">assignment</i>_x000D_
</section>_x000D_
<section id="sharp">_x000D_
<h2>Sharp</h2>_x000D_
<i class="material-icons-sharp">home</i>_x000D_
<i class="material-icons-sharp">assignment</i>_x000D_
</section>_x000D_
</body>_x000D_
_x000D_
</html>
_x000D_
EDIT #2: Here's a workaround to tint two-tone icons by using CSS image filters (code adapted from this comment):
body {_x000D_
font-family: Roboto, sans-serif;_x000D_
}_x000D_
_x000D_
.material-icons-two-tone {_x000D_
filter: invert(0.5) sepia(1) saturate(10) hue-rotate(180deg);_x000D_
font-size: 48px;_x000D_
}_x000D_
_x000D_
.material-icons,_x000D_
.material-icons-outlined,_x000D_
.material-icons-round,_x000D_
.material-icons-sharp {_x000D_
color: #0099ff;_x000D_
font-size: 48px;_x000D_
}
_x000D_
<!DOCTYPE html>_x000D_
<html>_x000D_
_x000D_
<head>_x000D_
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500|Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp">_x000D_
</head>_x000D_
_x000D_
<body>_x000D_
<section id="original">_x000D_
<h2>Baseline</h2>_x000D_
<i class="material-icons">home</i>_x000D_
<i class="material-icons">assignment</i>_x000D_
</section>_x000D_
<section id="outlined">_x000D_
<h2>Outlined</h2>_x000D_
<i class="material-icons-outlined">home</i>_x000D_
<i class="material-icons-outlined">assignment</i>_x000D_
</section>_x000D_
<section id="two-tone">_x000D_
<h2>Two tone</h2>_x000D_
<i class="material-icons-two-tone">home</i>_x000D_
<i class="material-icons-two-tone">assignment</i>_x000D_
</section>_x000D_
<section id="rounded">_x000D_
<h2>Rounded</h2>_x000D_
<i class="material-icons-round">home</i>_x000D_
<i class="material-icons-round">assignment</i>_x000D_
</section>_x000D_
<section id="sharp">_x000D_
<h2>Sharp</h2>_x000D_
<i class="material-icons-sharp">home</i>_x000D_
<i class="material-icons-sharp">assignment</i>_x000D_
</section>_x000D_
</body>_x000D_
_x000D_
</html>
_x000D_
Or view it on Codepen
I ended up using IcoMoon app to create a custom font using only the new themed icons I required for a recent web app build. It's not perfect but you can mimic the existing Google Font functionality pretty nicely with a little bit of setup. Here's a writeup:
If someone is feeling daring, they could convert the entire theme using IcoMoon. Hell, IcoMoon probably has an internal process that would make it easy since they already have the original Material Icons set in their library.
Anyway, this isn't a perfect solution, but it worked for me.
The Aj334's recent edit works perfectly.
<link href="https://fonts.googleapis.com/css?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp" rel="stylesheet">
<i class="material-icons">donut_small</i>
<i class="material-icons-outlined">donut_small</i>
<i class="material-icons-two-tone">donut_small</i>
<i class="material-icons-round">donut_small</i>
<i class="material-icons-sharp">donut_small</i>
For angular material you should use fontSet input to change the font family:
<link href="https://fonts.googleapis.com/css?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp"
rel="stylesheet" />
<mat-icon>edit</mat-icon>
<mat-icon fontSet="material-icons-outlined">edit</mat-icon>
<mat-icon fontSet="material-icons-two-tone">edit</mat-icon>
...
What worked for me is using _outline not _outlined after the icon name.
<mat-icon>info</mat-icon>
vs
<mat-icon>info_outline</mat-icon>
Put in head link to google styles
<link href="https://fonts.googleapis.com/icon?family=Material+Icons+Outlined" rel="stylesheet">
and in body something like this
<i class="material-icons-outlined">bookmarks</i>
I was unsatisfied that until know Google hasn't yet released their new designs as font or svg icon set. Therefore I put together a small npm package to solve the problem.
https://www.npmjs.com/package/ts-material-icons-svg
Simply import the icons you wanna use and add them to your registry. This also supports tree shaking since only those icons are added to your project that you really want and/or need.
npm i --save https://github.com/MarcusCalidus/ts-material-icons-svg.git
to use two tone icons for example
import {icon_edit} from 'ts-material-icons-svg/dist/twotone';
matIconRegistry.addSvgIcon(
'edit',
domSanitizer.bypassSecurityTrustResourceUrl(icon_edit),
);
In your html template you now can use the new icon
<mat-icon svgIcon="edit"></mat-icon>
1. include CSS:
<link href="https://fonts.googleapis.com/css?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp" rel="stylesheet">
2. Use it like this:
<i class="material-icons">account_balance</i>
<i class="material-icons material-icons-outlined">account_balance</i>
<i class="material-icons material-icons-two-tone">account_balance</i>
<i class="material-icons material-icons-sharp">account_balance</i>
<i class="material-icons material-icons-round">account_balance</i>
Note: For example, to use outlined style, You need to specify material-icons AND material-icons-outlined classes.
Source: Stackoverflow.com