Vue Feather Icons Component
Vue Feather is a component library providing easy integration of Feather icons into Vue 3 applications. The current stable version is `2.0.0`, which marks a significant upgrade to support Vue 3, diverging from previous versions compatible with Vue 2. The library follows Semantic Versioning guidelines, indicating predictable updates. Key differentiators include its lightweight nature, use of functional components for enhanced performance, and extensive customization options via props such as `animation`, `size`, `stroke`, and `type`. It functions as a wrapper around the `feather-icons` library, which must be installed separately as a peer dependency, providing the underlying SVG assets. Releases are infrequent but align with major Vue and Feather Icons updates, focusing on stability and compatibility.
Common errors
-
[Vue warn]: Failed to resolve component: vue-feather
cause The `VueFeather` component has not been correctly registered with the Vue application or is not imported into the component where it's being used.fixEnsure you either globally register the component using `app.component(VueFeather.name, VueFeather);` or locally import it and add it to your component's `components` option: `import VueFeather from 'vue-feather'; export default { components: { VueFeather } };` -
Error: Cannot find module 'feather-icons' or Module not found: Error: Can't resolve 'feather-icons'
cause The `feather-icons` package, a required peer dependency, is not installed in your project.fixInstall the `feather-icons` package using your preferred package manager: `npm install feather-icons@^4` or `yarn add feather-icons@^4` or `pnpm add feather-icons@^4`. -
Uncaught TypeError: Cannot read properties of undefined (reading 'name')
cause This typically occurs when `VueFeather` is `undefined`, often due to an incorrect import statement (e.g., trying to use `require` in an ESM context or using named import syntax for a default export).fixVerify your import statement is `import VueFeather from 'vue-feather';` for Vue 3 applications.
Warnings
- breaking Version `2.0.0` of `vue-feather` upgraded to support Vue 3. Applications using Vue 2 must remain on `vue-feather` v1.x.
- gotcha The `feather-icons` package is a required peer dependency and must be installed alongside `vue-feather` for the icons to render correctly.
- breaking In version `0.2.0`, the root element's class name for the icon component was changed from `vue-feather` to `feather`. This can break existing CSS selectors targeting the old class.
Install
-
npm install vue-feather -
yarn add vue-feather -
pnpm add vue-feather
Imports
- VueFeather
import VueFeather from 'vue-feather';
- VueFeather
const VueFeather = require('vue-feather');import VueFeather from 'vue-feather';
- VueFeather
import { VueFeather } from 'vue-feather';import VueFeather from 'vue-feather';
Quickstart
import { createApp } from 'vue';
import VueFeather from 'vue-feather';
const app = createApp({
template: `
<div>
<h1>Feather Icons Example</h1>
<vue-feather type="feather" animation="pulse" size="36"></vue-feather>
<vue-feather type="activity" stroke="red" stroke-width="3"></vue-feather>
<vue-feather type="camera" fill="blue" size="48"></vue-feather>
</div>
`
});
// Register the component globally
app.component(VueFeather.name, VueFeather);
app.mount('#app');
// To run this, you'd typically have an index.html with <div id="app"></div>
// and script type="module" src="main.js" (assuming this file is main.js).