vue.jsvuejs3vitematerial-design-icons

Vite + Vue3 in Electron: how to import and use Material Design Icons @mdi/font (or any other icon font)


I want to bundle @mdi/font icons into my application (it's an Electron app).

I installed npm i @mdi/font --save-dev:

  "devDependencies": {
    "@mdi/font": "^7.0.96",
  }

Then I imported css/scss, I tried several different ways:

Then I used mdi-* css classes in my markup:

SideMenu.vue:

<template>
  <aside class="menu">
    <ul class="action-bar">
      <li class="action-item active">
        <a class="action-label icon">
          <i class="mdi-cog"></i>
        </a>
      </li>
      <li class="action-item">
        <a class="action-label icon">
          <i class="mdi-home"></i>
        </a>
      </li>
      <li class="action-item">
        <a class="action-label icon">
          <i class="mdi-content-copy"></i>
        </a>
      </li>
    </ul>
  </aside>
</template>

The app starts and working but I see the same icon.

enter image description here

Things to consider:


Solution

  • Answering my own question. Thanks to @Duannx, the solution is very simple - just to add the missing mdi class:

    <a class="action-label icon">
      <i class="mdi mdi-cog"></i>
    </a>
    

    there's nothing specific to vite/vue/electron :)