Reputation: 906
According to the guideline in the Google Material website we have to use material icons in _i _ tag.
the question is how to add the icons as font-awesome. something like :
Class="material-icons face"
instead of
<i class="material-icons"> face </i>
Upvotes: 14
Views: 11783
Reputation: 261
It's also possible to create the selectors with Sass, if someone don't want to use data selectors.
$icons: "content_paste_search", "format-size", "search";
@each $icon in $icons {
.material-icons-#{$icon}:after {
content: $icon;
}
}
<span class="material-icons material-icons-search"></span>
Upvotes: 0
Reputation: 1016
You can use IcoMoon (an outstanding free tool to generate fonts). Set class, prefix/suffix etc to adjust then you can easily add icons by <i class="m-home"></i>
Upvotes: 0
Reputation: 7457
There's an easier way than the accepted answer. I got inspiration for this from the plugin css-toolip, which utilises the attr()
css function (surprisingly has high browser adoption).
While attr() is supported for effectively all browsers for the content property... https://caniuse.com/#search=css%20attr
<span class="material-icons" data-icon="face"></span>
.material-icons:after {
content: attr(data-icon);
}
This means that you don't have to add css for each icon that you want to use.
Upvotes: 16
Reputation: 2548
Yes,you can add the material icons as classes using the after pseudo elements.check out the fiddle
<span class="material-icons face"></span>
.face {
position:relative;
display:inline-block;
}
.face:after {
content: "face";
}
Upvotes: 16