Vue 3 Icon Component

3.0.3 · active · verified Sun Apr 19

Vue3 Icon is a dedicated Vue 3 component designed for effortlessly rendering SVG path-based icons within modern Vue applications. Currently stable at version 3.0.3, the library receives updates to maintain compatibility with the latest Vue releases and address evolving development practices. Its release cadence is moderate, typically involving major version bumps for significant architectural changes or new features, such as the shift to an ESM-first architecture in v3.0.0 and the adoption of Vite for its build process in v2.0.0. A key differentiator is its versatility, supporting icon data from popular libraries like Material Design Icons (`@mdi/js`), various Font Awesome packages, Simple Icons, and even custom SVG paths. It offers flexible props for controlling icon size, color, rotation, and custom viewbox settings, providing developers with granular control over icon presentation without bundling entire icon font libraries.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to globally register the `SvgIcon` component, import an icon path from Material Design Icons, and define a custom SVG path. It then renders both icons with basic styling in a Vue 3 application.

import { createApp } from 'vue';
import SvgIcon from 'vue3-icon';
import { mdiAccount } from '@mdi/js';

const app = createApp({
  setup() {
    const myCustomIcon = "M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z";
    return {
      mdiAccount,
      myCustomIcon
    };
  },
  template: `
    <div id="app">
      <h1>Vue3 Icon Example</h1>
      <p>Material Design Icon:</p>
      <svg-icon type="mdi" :path="mdiAccount" :size="48" style="color: dodgerblue;"></svg-icon>
      <p>Custom SVG Path Icon (with custom viewbox and color):</p>
      <svg-icon :path="myCustomIcon" size="24" viewbox="0 0 24 24" style="color: green;"></svg-icon>
    </div>
  `,
});

app.component("svg-icon", SvgIcon);
app.mount("#app");

view raw JSON →