- This topic has 1 reply, 2 voices, and was last updated 4 years, 10 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › General Discussions › Use Material icons in Vue template
Tagged: custom element, material icons vue, smart elements, smart framework, web component, web components
Hi,
I would like to use a material icon like this:
<smart-button id=”menu-btn”>
<i class=”material-icons”>menu</i>
</smart-button>
The code snippet shows me the text ‘menu’ instead of the image. I think I have to include a stylesheet. How should I do that in a Vue app?
Thanks
Hi olaf@xso,
Add the following CSS to you CSS stylesheet and import it in your App.vue file:
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(https://example.com/MaterialIcons-Regular.eot); /* For IE6-8 */
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url(https://example.com/MaterialIcons-Regular.woff2) format('woff2'),
url(https://example.com/MaterialIcons-Regular.woff) format('woff'),
url(https://example.com/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';
}
If you don’t want to fetch the icons from the web and instead use yout localy downloaded files from NPM just replace the urls in the font-face with the path to the appropriate files in your local storage.
Best Regards,
Christopher
Smart HTML Elements Team
https://www.htmlelements.com