Vue Icons Plus
Vue Icons Plus is a comprehensive collection of over 50,000 SVG icons from popular icon libraries, designed for easy integration into Vue.js projects. Supporting Vue 3 and Vue 2.7+, it allows developers to import and use icons directly as components. The package, currently at version 0.1.9, follows a modular import structure where icons are accessed from subdirectories corresponding to their original icon pack (e.g., `vue-icons-plus/fa` for Font Awesome). This design minimizes bundle size by only including the necessary icons. Its release cadence appears to be ad-hoc based on bug fixes and new icon pack additions. Key differentiators include its vast selection of icons and explicit support for both modern Vue setups and older Webpack environments through separate `@vue-icons-plus/sfc-X` packages, although these have install time trade-offs.
Common errors
-
This dependency was not found: * in ./node_modules/vue-icons-plus/...
cause Attempting to import an icon component directly from the root `vue-icons-plus` package or a non-existent sub-path, rather than the correct icon family directory.fixVerify that your import statement includes the specific icon family sub-path, e.g., `import { FaBeer } from 'vue-icons-plus/fa';` instead of `import { FaBeer } from 'vue-icons-plus';` -
Error: [Vue warn]: Failed to resolve component: FaBeer If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
cause The icon component was imported but not correctly registered or resolved in a Vue 2.7+ environment, or an incorrect import path was used.fixFor Vue 2.7+, ensure components are explicitly registered: `export default { components: { FaBeer } }`. For both Vue 2.7+ and Vue 3, double-check the import path for the icon component, especially the icon family sub-path.
Warnings
- gotcha Always import icon components from their specific icon family sub-paths (e.g., `vue-icons-plus/fa`, `vue-icons-plus/bi`). Attempting to import directly from the root `vue-icons-plus` package will result in undefined components or import errors, as the main package does not export individual icons directly.
- gotcha When using `vue-icons-plus` with Vue 2.7+, icon components must be explicitly registered within the `components` option of your Vue component. This manual registration step is typically not required for Vue 3 projects due to its automatic component resolution.
- gotcha For projects constrained by older bundler environments (e.g., Webpack 3 or 4) or very large projects, `vue-icons-plus` offers split packages (`@vue-icons-plus/sfc-1`, `@vue-icons-plus/sfc-2`, etc.). These packages have a significantly longer installation time and require different import paths (e.g., `import FaBeer from '@vue-icons-plus/sfc-1/fa/FaBeer';`).
- gotcha The separate `@vue-icons-plus/sfc-X` packages, while solving 'npm restrictions' for older bundlers, export icons as default components from their specific file paths. Using named imports (e.g., `import { FaBeer } from ...`) with these packages will lead to `undefined` imports or runtime errors.
Install
-
npm install vue-icons-plus -
yarn add vue-icons-plus -
pnpm add vue-icons-plus
Imports
- FaBeer
import FaBeer from 'vue-icons-plus/fa'; const { FaBeer } = require('vue-icons-plus/fa');import { FaBeer } from 'vue-icons-plus/fa'; - BiSearch
import { BiSearch } from 'vue-icons-plus'; import BiSearch from 'vue-icons-plus/bi';import { BiSearch } from 'vue-icons-plus/bi'; - FaBeer (Webpack 3/4)
import { FaBeer } from '@vue-icons-plus/sfc-1/fa/FaBeer';import FaBeer from '@vue-icons-plus/sfc-1/fa/FaBeer';
Quickstart
<script setup lang="ts">
import { FaBeer } from "vue-icons-plus/fa";
import { BiSearch } from "vue-icons-plus/bi";
import { MdHome } from "vue-icons-plus/md"; // Assuming MdHome exists in Material Design pack
</script>
<template>
<div class="icon-showcase">
<h1>My Icon Showcase</h1>
<p>Enjoy a refreshing beer:</p>
<FaBeer class="icon large-icon" />
<p>Search for something great:</p>
<BiSearch class="icon medium-icon" />
<p>Go back home:</p>
<MdHome class="icon small-icon" />
<p>These icons are imported directly and rendered as SVG components in Vue 3.</p>
</div>
</template>
<style>
.icon-showcase {
font-family: sans-serif;
padding: 20px;
text-align: center;
}
.icon {
display: inline-block;
vertical-align: middle;
margin: 10px;
color: #3498db; /* Example color */
}
.large-icon { font-size: 3em; }
.medium-icon { font-size: 2em; }
.small-icon { font-size: 1.5em; }
</style>