
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
vue-svg-iconx
Advanced tools
Svg icon component based on vue
npm i vue-svg-iconx
npm i svg-sprite-loader svgo svgo-loader -D
You need a directory to store your SVG icon files. For example:
src/assets/icon
You may need to give your icon a prefix. For example:
icon-
You can change them to whatever value you want
vue.config.js
const path = require("path");
function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports = {
chainWebpack(config) {
config.module
.rule("svg")
.exclude.add(resolve("src/assets/icon")) // This is your svg icon directory.
.end();
config.module
.rule("svg-icon")
.test(/\.(svg)(\?.*)?$/)
.include.add(resolve("src/assets/icon")) // This is your svg icon directory.
.end()
.use("svg-sprite-loader")
.loader("svg-sprite-loader")
.options({
symbolId: "icon-[name]" // This is your icon prefix
})
.end()
.use("svgo-loader")
.loader("svgo-loader")
.options({
externalConfig: resolve("svgo.yml") // svgo config file
})
.end();
}
};
svgo.yml
plugins:
- cleanupAttrs: true
- removeDoctype: true
- removeComments: true
- removeTitle: true
- removeDesc: true
import iconx from "vue-svg-iconx";
// Import all svg, svg-sprite-loader and svgo-loader will automatically handle them for you
const requireAll = requireContext => requireContext.keys().map(requireContext);
requireAll(require.context("@/assets/icon", false, /\.svg$/));
Vue.use(iconx);
<template>
<div>
<iconx name="loading"></iconx>
Support rotate
<iconx rotate name="loading" color="#000" size="100px"></iconx>
</div>
</template>
name <String>
required: Yes.
The value of name is equal to the file name of the svg you want to display.
color <String>
required: No
size <String, Array>
required: No
example:
<icon name="loading" size="50px"></icon>
->
<svg style="font-size: 50px">...</svg>
--------------------------------------------------------
<icon name="loading" :size="['50px']"></icon>
->
<svg style="width: 50px; height: 50px">...</svg>
--------------------------------------------------------
<icon name="loading" :size="['50px', '60px']"></icon>
->
<svg style="width: 50px; height: 60px">...</svg>
rotate <Boolean>
required: No
Support for custom component names and global icon prefixes when registering.
import iconx from "vue-svg-iconx";
Vue.use(iconx, {
componentName: "icon" // default: iconx
prefix: 'iconx-' // default: icon-
});
FAQs
Svg icon component based on vue
We found that vue-svg-iconx demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.