HTML Elements Forums Framework Use Material icons in Vue template

This topic contains 1 reply, has 2 voices, and was last updated by Avatar Hristofor 2 weeks, 6 days ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #100595
    Avatar
    olaf@xso
    Participant

    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

    #100598
    Avatar
    Hristofor
    Participant

    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

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.