Iconsax Icon Pack for Vue
vue-iconsax is a JavaScript package providing a comprehensive set of Iconsax icons specifically designed for Vue 3 applications. It is currently at version 2.0.0 and focuses on delivering 6000 icons across 6 distinct design styles (Linear, Outline, TwoTone, Bulk, Broken, Bold), all meticulously crafted on a 24px grid. The library emphasizes lightweight usage and ease of integration, differentiating itself by exclusively supporting Vue 3 and offering dynamic icon loading through a single `VsxIcon` component. This approach streamlines icon usage by eliminating the need for individual icon imports, enabling developers to render any available icon simply by passing its PascalCase name as a prop. The package's release cadence appears tied to updates from the core Iconsax library and Vue 3 ecosystem developments.
Common errors
-
Failed to resolve component: VsxIcon
cause The `VsxIcon` component has not been correctly registered within your Vue application, either globally or locally.fixGlobally register the component in your `main.js` file using `app.component('VsxIcon', VsxIcon)` or import and declare it in the `components` option of your specific Vue component. -
Icon not displaying, or showing as a blank space/broken image.
cause This usually indicates an incorrect `iconName` prop value (e.g., misspelled, wrong casing) or an invalid `type` prop.fixDouble-check that the `iconName` prop exactly matches an existing Iconsax icon in PascalCase and that the `type` prop (e.g., 'linear', 'bold', 'broken') is one of the six supported values and correctly spelled. -
Uncaught SyntaxError: Cannot use import statement outside a module
cause This error occurs when trying to use ES module `import` syntax in a CommonJS environment (e.g., older Node.js versions or misconfigured bundlers). `vue-iconsax` is an ESM-only package.fixEnsure your project is configured for ES Modules. If using Node.js, add `"type": "module"` to your `package.json` or use `.mjs` file extensions. For bundlers like Webpack or Vite, ensure they are configured to handle ES Modules correctly.
Warnings
- breaking vue-iconsax v2.0.0 and subsequent versions are exclusively designed for Vue 3 and are not compatible with Vue 2 applications. Attempting to use it in a Vue 2 project will result in runtime errors.
- gotcha The `iconName` prop for the `VsxIcon` component strictly requires icon names to be provided in PascalCase (e.g., 'Add', 'Home', 'UserSearch'). Using kebab-case, snake_case, or any other casing will result in the icon not rendering.
- gotcha This library does not support individual icon component imports (e.g., `import { AddIcon } from 'vue-iconsax'`). All icons are dynamically loaded and rendered solely through the generic `VsxIcon` component by specifying the icon's name via the `iconName` prop.
Install
-
npm install vue-iconsax -
yarn add vue-iconsax -
pnpm add vue-iconsax
Imports
- VsxIcon
const VsxIcon = require('vue-iconsax')import { VsxIcon } from 'vue-iconsax' - VsxIcon (for global registration)
import VsxIcon from 'vue-iconsax'
import { VsxIcon } from 'vue-iconsax' - VsxIcon (for local registration)
import { Vsxicon } from 'vue-iconsax'import { VsxIcon } from 'vue-iconsax'
Quickstart
import { createApp, ref } from 'vue';
import App from './App.vue';
import { VsxIcon } from 'vue-iconsax';
// main.js - Global registration of VsxIcon component
const app = createApp(App);
app.component('VsxIcon', VsxIcon);
app.mount('#app');
// App.vue - Example usage in a Vue component
export default {
name: 'App',
setup() {
const iconNames = ['Activity', 'Archive1', 'Bookmark', 'Chart', 'Cloud'];
let currentIndex = ref(0);
const currentIcon = ref(iconNames[currentIndex.value]);
const cycleIcon = () => {
currentIndex.value = (currentIndex.value + 1) % iconNames.length;
currentIcon.value = iconNames[currentIndex.value];
};
return {
currentIcon,
cycleIcon
};
},
template: `
<div id="app" style="font-family: Avenir, Helvetica, Arial, sans-serif; text-align: center; color: #2c3e50; margin-top: 60px; display: flex; flex-direction: column; align-items: center; gap: 20px;">
<h1>Dynamic Iconsax Demo</h1>
<VsxIcon :iconName="currentIcon" color="#4a90e2" size="64" type="twotone" />
<p>Current Icon: <strong>{{ currentIcon }}</strong></p>
<button @click="cycleIcon" style="padding: 10px 20px; font-size: 1em; cursor: pointer; border: 1px solid #4a90e2; background-color: #4a90e2; color: white; border-radius: 5px;">Next Icon</button>
</div>
`
};