Installations
npm install vue-awesome
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>= 4.0.0
Node Version
14.17.2
NPM Version
8.1.3
Contributors
Unable to fetch Contributors
Languages
JavaScript (97.85%)
Vue (2.1%)
HTML (0.04%)
Smarty (0.01%)
Developer
Download Statistics
Total Downloads
5,816,028
Last Day
3,201
Last Week
16,665
Last Month
76,326
Last Year
886,270
GitHub Statistics
2,432 Stars
145 Commits
206 Forks
43 Watching
17 Branches
11 Contributors
Bundle Size
1.12 MB
Minified
355.43 kB
Minified + Gzipped
Package Meta Information
Latest Version
4.5.0
Package Id
vue-awesome@4.5.0
Unpacked Size
2.46 MB
Size
790.92 kB
File Count
1,617
NPM Version
8.1.3
Node Version
14.17.2
Total Downloads
Cumulative downloads
Total Downloads
5,816,028
Last day
-15.6%
3,201
Compared to previous day
Last week
-13.7%
16,665
Compared to previous week
Last month
-1.8%
76,326
Compared to previous month
Last year
8.1%
886,270
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
Dev Dependencies
33
Vue-Awesome
Awesome SVG icon component for Vue.js, with built-in Font Awesome icons.
Vue-Awesome an SVG icon component for Vue.js, with built-in icons courtesy of Font Awesome.
Check out the demo here.
Installation
npm (Recommended)
1$ npm install vue-awesome
bower
1$ bower install vue-awesome
Manual
Just download dist/vue-awesome.js
and include it in your HTML file:
1<script src="path/to/vue-awesome/dist/vue-awesome.js"></script>
Usage
1<!-- basic --> 2<v-icon name="beer"/> 3 4<!-- with options --> 5<v-icon name="sync" scale="2" spin/> 6<v-icon name="comment" flip="horizontal"/> 7<v-icon name="code-branch" label="Forked Repository"/> 8 9<!-- stacked icons --> 10<v-icon label="No Photos"> 11 <v-icon name="camera"/> 12 <v-icon name="ban" scale="2" class="alert"/> 13</v-icon>
Font Awesome 5 has separated all icons into several packs. Vue-Awesome is built upon its all free icons, which includes all free icons from 3 icon packs: regular
, solid
and brands
. Since the solid
pack has the most number of icons, we organize all Vue-Awesome icons as follows:
-
All icons from
solid
pack are located invue-awesome/icons
directory and have unprefixedname
prop values. -
Icons from
regular
andbrands
are located invue-awesome/icons/regular
andvue-awesome/icons/brands
, which have prefixedname
prop values likeregular/flag
orbrands/reddit
.
You can find all available name
values from Font Awesome's website like beer
, file
and camera
.
ES Modules with NPM & vue-loader (Recommended)
1import Vue from 'vue' 2 3/* Pick one way between the 2 following ways */ 4 5// only import the icons you use to reduce bundle size 6import 'vue-awesome/icons/flag' 7 8// or import all icons if you don't care about bundle size 9import 'vue-awesome/icons' 10 11/* Register component with one of 2 methods */ 12 13import Icon from 'vue-awesome/components/Icon' 14 15// globally (in your main .js file) 16Vue.component('v-icon', Icon) 17 18// or locally (in your component file) 19export default { 20 components: { 21 'v-icon': Icon 22 } 23}
⚠️ Heads up
Importing the souce version
If you are using official Vue CLI to create your project and you want to use the untranspiled component (import vue-awesome/components/Icon
rather than import vue-awesome
directly, to optimize bundle size, which is recommended), you'll encounter the problem that the default configuration will exclude node_modules
from files to be transpiled by Babel.
For Vue CLI 3+, add vue-awesome
into transpileDependencies
in vue.config.js
like this:
1// vue.config.js 2module.exports = { 3 transpileDependencies: [ 4 /\bvue-awesome\b/ 5 ] 6}
For Vue CLI 2 with the webpack
template, modify build/webpack.base.conf.js
like this:
1 { 2 test: /\.js$/, 3 loader: 'babel-loader', 4- include: [resolve('src'), resolve('test')] 5+ include: [ 6+ resolve('src'), 7+ resolve('test'), 8+ resolve('node_modules/vue-awesome') 9+ ] 10 }
If you are using bare webpack config, just do similar modifications make it work.
Using with Nuxt.js
When using Vue-Awesome on the server side with Nuxt.js, it may prompt Unexpected token import
because Nuxt.js has configured an external
option by default, which prevent files under node_modules
from being bundled into the server bundle with only a few exceptions. We need to whitelist vue-awesome
in nuxt.config.js
as follows:
For Nuxt.js 2:
1 2module.exports = { 3 // ... 4 build: { 5 transpile: [/^vue-awesome/] 6 } 7}
For Nuxt.js 1:
1// Don't forget to 2// npm i --save-dev webpack-node-externals 3const nodeExternals = require('webpack-node-externals') 4 5module.exports = { 6 // ... 7 build: { 8 extend (config, { isServer }) { 9 // ... 10 if (isServer) { 11 config.externals = [ 12 nodeExternals({ 13 // default value for `whitelist` is 14 // [/es6-promise|\.(?!(?:js|json)$).{1,5}$/i] 15 whitelist: [/es6-promise|\.(?!(?:js|json)$).{1,5}$/i, /^vue-awesome/] 16 }) 17 ] 18 } 19 } 20 } 21}
Unit Testing with Jest
Make sure to whitelist vue-awesome
from the transformIgnorePattern
. Add following configuation in test/unit/jest.conf.js
:
1+ transformIgnorePatterns: [ 2+ '/node_modules(?![\\\\/]vue-awesome[\\\\/])/' 3+ ],
Don't import all icons if you don't want to make unit testing slow because this will transform all icons from ES module and thus slow down the test process.
CommonJS with NPM without ES Next support
1var Vue = require('vue') 2 3// requiring the UMD module 4var Icon = require('vue-awesome') 5 6// or with vue-loader you can require the src directly 7var Icon = require('vue-awesome/components/Icon') 8 9// register component to use
AMD
1require.config({ 2 paths: { 3 'vue-awesome': 'path/to/vue-awesome' 4 } 5}) 6 7require(['vue-awesome'], function (Icon) { 8 // register component to use 9 Vue.component('v-icon', Icon) 10})
Global variable
The component class is exposed as window.VueAwesome
.
1// register component to use 2Vue.component('v-icon', VueAwesome)
Props
-
name: string
The name of the icon. It's necessary if the component isn't used as the wrapper of an icon stack. All valid names correspond to the file path relative to the
icons
directory. Notice that you may have to check the name of the icon pack after you search on FontAwesome's website. For example, you'll see a URL argument ofstyle=brands
on the detail page for500px
and the icon name will bebrands/500px
.Only free icons for FontAwesome are available by default and because the
solid
style has the most icons, we've made it the default pack so the path prefixes can be omitted.If you pass
null
to this prop, the whole component will not be rendered. -
scale: number|string
Used to adjust the size of the icon. Default to
1
. -
spin: boolean
Used to specify whether the icon is spining. Default to
false
. (Can't use together withpulse
.) -
pulse: boolean
Set the pulse effect to the icon. Default to
false
. (Can't use together withspin
.) -
inverse: boolean
If set to
true
, the color of the icon will become#fff
. Default tofalse
. -
flip: 'vertical'|'horizontal'|'both'
Used to flip the icon.
-
label: string
Set the
aria-label
for the icon if provided. -
title: string
Set the title for the icon.
The icon will have
role="presentation"
thus not accessible when neitherlabel
nortitle
exists.
Misc
If you are using vue-awesome/components/Icon
(instead of the whole bundled version), Vue-Awesome won't import a single icon by default. Do not forget to import icons you want to use.
If these caveats don't help and there are no proper workarounds in earlier issues, please feel free to file a new one.
Styling
Dynamic sizing
You can make the icons scale dynamically according to your font-size
by adding the following CSS:
1.fa-icon { 2 width: auto; 3 height: 1em; /* or any other relative font sizes */ 4 5 /* You would have to include the following two lines to make this work in Safari */ 6 max-width: 100%; 7 max-height: 100%; 8}
Colors
The icon color is inherited from the font color of the parent element by default. You can easily change it to any other color by specifying the color
property.
Local development
1$ npm i 2$ npm run dev
Open http://localhost:8080/demo
to see the demo.
Updating icons
Don't touch files in src/icons
but update assets/svg/*
instead and run npm run icons
to re-generate icon module files.
Registering custom icons
Simple case
You can register custom icons like this:
1import Icon from 'vue-awesome/components/Icon' 2 3Icon.register({ 4 baidu: { 5 width: 23.868, 6 height: 26, 7 d: 'M3.613 13.701c2.827-.608 2.442-3.986 2.357-4.725-.138-1.139-1.477-3.128-3.296-2.971C.386 6.21.052 9.515.052 9.515c-.309 1.528.74 4.793 3.561 4.186zm3.002 5.875c-.083.238-.268.846-.107 1.375.315 1.187 1.346 1.24 1.346 1.24h1.48v-3.619H7.749c-.713.213-1.057.767-1.134 1.004zM8.86 8.035c1.562 0 2.823-1.797 2.823-4.019C11.683 1.796 10.421 0 8.86 0 7.301 0 6.036 1.796 6.036 4.016c0 2.222 1.265 4.019 2.824 4.019zm6.724.265c2.087.271 3.429-1.956 3.695-3.644.272-1.686-1.074-3.644-2.552-3.98-1.48-.339-3.329 2.032-3.497 3.578-.2 1.89.271 3.778 2.354 4.046zm5.114 9.923s-3.229-2.498-5.113-5.198c-2.555-3.981-6.185-2.361-7.399-.337-1.209 2.024-3.093 3.305-3.36 3.644-.271.334-3.9 2.293-3.095 5.871.806 3.576 3.635 3.508 3.635 3.508s2.085.205 4.504-.336c2.42-.537 4.503.134 4.503.134s5.652 1.893 7.199-1.751c1.545-3.645-.874-5.535-.874-5.535zm-9.671 5.423H7.352c-1.587-.316-2.219-1.4-2.299-1.584-.078-.188-.528-1.059-.29-2.539.686-2.219 2.642-2.379 2.642-2.379h1.956V14.74l1.666.025v8.881zm6.844-.025h-4.229c-1.639-.423-1.716-1.587-1.716-1.587v-4.677l1.716-.027v4.203c.104.447.661.529.661.529h1.742v-4.705h1.825v6.264zm5.986-12.486c0-.808-.671-3.239-3.159-3.239-2.492 0-2.825 2.295-2.825 3.917 0 1.548.131 3.71 3.227 3.641 3.096-.068 2.757-3.507 2.757-4.319z' 8 } 9})
More advanced cases
If your SVG file has more than one path or polygon, and/or you want to have a predefined style, you can register like this:
Paths
1import Icon from 'vue-awesome/components/Icon' 2 3Icon.register({ 4 webpack: { 5 width: 1200, 6 height: 1200, 7 paths: [ 8 { 9 style: 'fill:#8ED6FB', 10 d: 'M1035.6 879.3l-418.1 236.5V931.6L878 788.3l157.6 91zm28.6-25.9V358.8l-153 88.3V765l153 88.4zm-901.5 25.9l418.1 236.5V931.6L320.3 788.3l-157.6 91zm-28.6-25.9V358.8l153 88.3V765l-153 88.4zM152 326.8L580.8 84.2v178.1L306.1 413.4l-2.1 1.2-152-87.8zm894.3 0L617.5 84.2v178.1l274.7 151.1 2.1 1.2 152-87.8z' 11 }, 12 { 13 style: 'fill:#1C78C0', 14 d: 'M580.8 889.7l-257-141.3v-280l257 148.4v272.9zm36.7 0l257-141.3v-280l-257 148.4v272.9zm-18.3-283.6zM341.2 436l258-141.9 258 141.9-258 149-258-149z' 15 } 16 ] 17 } 18})
Polygons
1import Icon from 'vue-awesome/components/Icon' 2 3Icon.register({ 4 vue: { 5 width: 256, 6 height: 221, 7 polygons: [ 8 { 9 style: 'fill:#41B883', 10 points: '0,0 128,220.8 256,0 204.8,0 128,132.48 50.56,0 0,0' 11 }, 12 { 13 style: 'fill:#35495E', 14 points: '50.56,0 128,133.12 204.8,0 157.44,0 128,51.2 97.92,0 50.56,0' 15 } 16 ] 17 } 18})
Raw SVG
If you are using Vue.js version prior to 2.6.0
, you need to include innersvg-polyfill before you use this feature.
1import Icon from 'vue-awesome/components/Icon' 2 3Icon.register({ 4 'html5-c': { 5 width: 512, 6 height: 512, 7 raw: '<path fill="#E34F26" d="M71,460 L30,0 481,0 440,460 255,512"/><path fill="#EF652A" d="M256,472 L405,431 440,37 256,37"/><path fill="#EBEBEB" d="M256,208 L181,208 176,150 256,150 256,94 255,94 114,94 115,109 129,265 256,265zM256,355 L255,355 192,338 188,293 158,293 132,293 139,382 255,414 256,414z"/><path fill="#FFF" d="M255,208 L255,265 325,265 318,338 255,355 255,414 371,382 372,372 385,223 387,208 371,208zM255,94 L255,129 255,150 255,150 392,150 392,150 392,150 393,138 396,109 397,94z"/>' 8 } 9})
No vulnerabilities found.
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
no binaries found in the repo
Reason
Found 1/25 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 6 are checked with a SAST tool
Reason
69 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-phwq-j96m-2c2q
- Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-6h5x-7c5m-7cr7
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-74fj-2j2h-c42q
- Warn: Project is vulnerable to: GHSA-pw2r-vq6v-hr8c
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-pfq8-rq6v-vf5m
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-5rrq-pxf6-6jx5
- Warn: Project is vulnerable to: GHSA-8fr3-hfg3-gpgp
- Warn: Project is vulnerable to: GHSA-gf8q-jrpm-jvxq
- Warn: Project is vulnerable to: GHSA-2r2c-g63r-vccr
- Warn: Project is vulnerable to: GHSA-cfm4-qjh2-4765
- Warn: Project is vulnerable to: GHSA-x4jg-mjrx-434g
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-566m-qj78-rww5
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-3965-hpx2-q597
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-h9rv-jmmf-4pgx
- Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-rqff-837h-mm52
- Warn: Project is vulnerable to: GHSA-8v38-pw62-9cw2
- Warn: Project is vulnerable to: GHSA-hgjh-723h-mx2j
- Warn: Project is vulnerable to: GHSA-jf5r-8hm2-f872
- Warn: Project is vulnerable to: GHSA-5j4c-8p2g-v4jx
- Warn: Project is vulnerable to: GHSA-g3ch-rx76-35fx
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc
Score
1.7
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More