I manage this using ion-icon
instead i class="material-icons"
element.
I think this could be better because it’s less work rewriting code if I decide to use ion icons set
Here is the source I use to archive this.
This is the css that allows use ion-icon with material-icons
ion-icon[material-icons]:before{
@extend .material-icons;
content: attr(name);
}
Install material-desgn-icons
npm install material-design-icons
Change gulpfile
gulpfile.js
// code hidden
gulp.task('sass', buildSass);
gulp.task('html', copyHTML);
var fontOptions = {
src: ['node_modules/ionic-angular/fonts/**/*.+(ttf|woff|woff2)',
'node_modules/material-design-icons/iconfont/*.+(eot|ttf|woff|woff2)']
};
gulp.task('fonts', function() {
return copyFonts(fontOptions);
});
gulp.task('scripts', copyScripts);
// code hidden
Add to app.core.scss
app.core.scss
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(../fonts/MaterialIcons-Regular.eot); /* For IE6-8 */
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url(../fonts/MaterialIcons-Regular.woff2) format('woff2'),
url(../fonts/MaterialIcons-Regular.woff) format('woff'),
url(../fonts/MaterialIcons-Regular.ttf) format('truetype');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px; /* Preferred icon size */
display: inline-block;
line-height: 1;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;
/* 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';
}
/* Rules for sizing the icon. */
.material-icons.md-18 { font-size: 18px; }
.material-icons.md-24 { font-size: 24px; }
.material-icons.md-36 { font-size: 36px; }
.material-icons.md-48 { font-size: 48px; }
/* Rules for using icons as black on a light background. */
.material-icons.md-dark { color: rgba(0, 0, 0, 0.54); }
.material-icons.md-dark.md-inactive { color: rgba(0, 0, 0, 0.26); }
/* Rules for using icons as white on a dark background. */
.material-icons.md-light { color: rgba(255, 255, 255, 1); }
.material-icons.md-light.md-inactive { color: rgba(255, 255, 255, 0.3); }
/* Extends material-icons to ion-icon elements */
ion-icon[material-icons]:before{
@extend .material-icons;
content: attr(name);
}
With this code, it is possible to use:
ion-icon material-icons name="material icon set"
ion-icon name="ion icon set"
i class="material-icons"