
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@fortawesome/vue-fontawesome
Advanced tools
@fortawesome/vue-fontawesome is a Vue.js component for integrating Font Awesome icons into your Vue applications. It allows you to easily use Font Awesome icons in your Vue components, providing a wide range of icons and customization options.
Basic Icon Usage
This feature allows you to use Font Awesome icons in your Vue components. You need to import the necessary icons and add them to the library, then use the <font-awesome-icon> component to display the icon.
<template>
<div>
<font-awesome-icon :icon="['fas', 'coffee']" />
</div>
</template>
<script>
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faCoffee } from '@fortawesome/free-solid-svg-icons'
library.add(faCoffee)
export default {
components: {
FontAwesomeIcon
}
}
</script>
Customizing Icon Size
This feature allows you to customize the size of the icons. You can use the `size` prop to set the size of the icon, such as `1x`, `2x`, `3x`, etc.
<template>
<div>
<font-awesome-icon :icon="['fas', 'coffee']" size="3x" />
</div>
</template>
<script>
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faCoffee } from '@fortawesome/free-solid-svg-icons'
library.add(faCoffee)
export default {
components: {
FontAwesomeIcon
}
}
</script>
Using Different Icon Styles
This feature allows you to use different styles of icons, such as solid, regular, and light. You need to import the icons from the respective Font Awesome packages and add them to the library.
<template>
<div>
<font-awesome-icon :icon="['fas', 'coffee']" />
<font-awesome-icon :icon="['far', 'coffee']" />
<font-awesome-icon :icon="['fal', 'coffee']" />
</div>
</template>
<script>
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faCoffee as fasCoffee } from '@fortawesome/free-solid-svg-icons'
import { faCoffee as farCoffee } from '@fortawesome/free-regular-svg-icons'
import { faCoffee as falCoffee } from '@fortawesome/pro-light-svg-icons'
library.add(fasCoffee, farCoffee, falCoffee)
export default {
components: {
FontAwesomeIcon
}
}
</script>
vue-awesome is a Vue.js component for displaying Font Awesome icons. It provides a simple way to use Font Awesome icons in your Vue applications, similar to @fortawesome/vue-fontawesome. However, it may not support the latest Font Awesome features and icons as comprehensively as @fortawesome/vue-fontawesome.
vue-fontawesome-icon is another Vue.js component for integrating Font Awesome icons. It offers similar functionality to @fortawesome/vue-fontawesome, allowing you to use Font Awesome icons in your Vue components. The main difference is in the API and the way icons are imported and used.
Font Awesome 5 Vue component using SVG with JS
Hey there! We're glad you're here...
If you've used Font Awesome in the past (version 4 or older) there are some things that you should learn before you dive in.
This package is for integrating with Vue.js. If you aren't using Vue then it's not going to help you. Head over to our "Get Started" page for some guidance.
This package, under the hood, uses SVG with JS and the @fortawesome/fontawesome-svg-core
library. This implementation differs drastically from
the web fonts implementation that was used in version 4 and older of Font Awesome. You might head over there to learn about how it works.
See UPGRADING.md.
You might also be interested in the larger umbrella project UPGRADING.md
$ npm i --save @fortawesome/fontawesome-svg-core
$ npm i --save @fortawesome/free-solid-svg-icons
$ npm i --save @fortawesome/vue-fontawesome
Brands are separated into their own style and for customers upgrading from version 4 to 5 we have a limited number of Regular icons available.
Visit fontawesome.com/icons to search for free and Pro icons
$ npm i --save @fortawesome/free-brands-svg-icons
$ npm i --save @fortawesome/free-regular-svg-icons
If you are a Font Awesome Pro subscriber you can install Pro packages.
$ npm i --save @fortawesome/pro-solid-svg-icons
$ npm i --save @fortawesome/pro-regular-svg-icons
$ npm i --save @fortawesome/pro-light-svg-icons
Using the Pro packages requires additional configuration.
$ yarn add @fortawesome/fontawesome-svg-core
$ yarn add @fortawesome/free-solid-svg-icons
$ yarn add @fortawesome/vue-fontawesome
The following examples are based on a project configured with vue-cli.
src/main.js
import Vue from 'vue'
import App from './App'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faCoffee } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
library.add(faCoffee)
Vue.component('font-awesome-icon', FontAwesomeIcon)
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
el: '#app',
components: { App },
template: '<App/>'
})
src/App.js
<template>
<div id="app">
<font-awesome-icon icon="coffee" />
</div>
</template>
<script>
export default {
name: 'App'
}
</script>
If you are using inline templates or HTML as templates you need to be careful to avoid self-closing tags.
See this issue on the Vue.js project
If you are writing these types of templates make sure and use valid HTML syntax:
<font-awesome-icon icon="coffee"></font-awesome-icon>
<i>
tags into <svg>
using Font AwesomeA basic installation of Font Awesome has
the ability to automatically transform <i class="fas fa-coffee"></i>
into
<svg class="...">...</svg>
icons. This technology works with the browser's
DOM, requestAnimationFrame
, and MutationObserver
.
When using the @fortawesome/fontawesome-svg-core
package this behavior is
disabled by default. This project uses that package so you will have to
explicitly enable it like this:
import { dom } from '@fortawesome/fontawesome-svg-core'
dom.watch() // This will kick of the initial replacement of i to svg tags and configure a MutationObserver
The icon
property of the FontAwesomeIcon
component can be used in the following way:
fas
:<font-awesome-icon icon="spinner" />
<font-awesome-icon :icon="['fas', 'spinner']" /> # Same as above
For the above to work you must add the spinner
icon to the library.
import { library } from '@fortawesome/fontawesome-svg-core'
import { faSpinner } from '@fortawesome/free-solid-svg-icons'
library.add(faSpinner)
<font-awesome-icon :icon="['far', 'spinner']" />
For the above to work you must add the regular spinner
icon (Pro only) to the library.
import { library } from '@fortawesome/fontawesome-svg-core'
import { faSpinner } from '@fortawesome/pro-regular-svg-icons'
library.add(faSpinner)
<template>
<div id="app">
<font-awesome-icon icon="appIcon" />
</div>
</template>
<script>
import { faChessQueen } from '@fortawesome/free-solid-svg-icons'
export default {
name: 'App',
computed: {
appIcon () {
return faChessQueen
}
}
}
</script>
With Vue you can tell your component to resolve other component explicitly.
<template>
<div>
<font-awesome-icon :icon="myIcon" />
</div>
</template>
<script>
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { faSpinner } from '@fortawesome/free-solid-svg-icons'
export default {
name: 'MyComponent',
data () {
return {
myIcon: faSpinner
}
},
components: {
FontAwesomeIcon
}
}
</script>
Explicitly selecting icons offer the advantage of only bundling the icons that you use in your final bundled file. This allows us to subset Font Awesome's thousands of icons to just the small number that are normally used.
import { library } from '@fortawesome/fontawesome-svg-core'
import { faCoffee } from '@fortawesome/free-solid-svg-icons'
import { faSpinner } from '@fortawesome/pro-light-svg-icons'
library.add(faCoffee, fab, faSpinner)
import { fab } from '@fortawesome/free-brands-svg-icons'
library.add(fab)
This will add the entire brands style to your library. Be careful with this approach as it may be convenient in the beginning but your bundle size will be large. We highly recommend that you take advantage of subsetting through tree shaking.
Keeping the bundles small when using import { faCoffee }
relies on
tree-shaking.
If you are not using a tool that supports tree shaking you may end up bundling more
icons than you intend. Here are some alternative import syntaxes:
import { library } from '@fortawesome/fontawesome-svg-core'
import faCoffee from '@fortawesome/free-solid-svg-icons/faCoffee'
import faSpinner from '@fortawesome/pro-light-svg-icons/faSpinner'
library.add(faCoffee, faSpinner)
How does this work? We have individual icon files like
node_modules/@fortawesome/free-solid-svg-icons/faCoffee.js
that contain just
that specific icon.
The following features are available as part of Font Awesome.
To use the following examples you must first register your component so Vue is aware of it.
A good place to do this is in main.js
or in the module you are calling new Vue()
. Make sure you register the component and have added icons to your
library before you bootstrap your Vue application.
import Vue from 'vue'
import { FontAwesomeIcon, FontAwesomeLayers, FontAwesomeLayersText } from 'vue-fontawesome'
Vue.component('font-awesome-icon', FontAwesomeIcon)
Vue.component('font-awesome-layers', FontAwesomeLayers)
Vue.component('font-awesome-layers-text', FontAwesomeLayersText)
Spin and pulse animation:
<font-awesome-icon icon="spinner" spin />
<font-awesome-icon icon="spinner" pulse />
Fixed width:
<font-awesome-icon icon="spinner" fixed-width />
Border:
<font-awesome-icon icon="spinner" border />
Flip horizontally, vertically, or both:
<font-awesome-icon icon="spinner" flip="horizontal" />
<font-awesome-icon icon="spinner" flip="vertical" />
<font-awesome-icon icon="spinner" flip="both" />
Size:
<font-awesome-icon icon="spinner" size="xs" />
<font-awesome-icon icon="spinner" size="lg" />
<font-awesome-icon icon="spinner" size="6x" />
Rotate:
<font-awesome-icon icon="spinner" rotation="90" />
<font-awesome-icon icon="spinner" rotation="180" />
<font-awesome-icon icon="spinner" rotation="270" />
Pull left or right:
<font-awesome-icon icon="spinner" pull="left" />
<font-awesome-icon icon="spinner" pull="right" />
Power Transforms:
<font-awesome-icon icon="spinner" transform="shrink-6 left-4" />
<font-awesome-icon icon="spinner" :transform="{ rotate: 42 }" />
Masking:
<font-awesome-icon icon="coffee" :mask="['far', 'circle']" />
Symbols:
<font-awesome-icon icon="edit" symbol />
<font-awesome-icon icon="edit" symbol="edit-icon" />
Layers:
<font-awesome-layers class="fa-lg">
<font-awesome-icon icon="circle" />
<font-awesome-icon icon="check" transform="shrink-6" style="color: white;" />
</font-awesome-layers>
Layers text:
<font-awesome-layers full-width class="fa-4x">
<font-awesome-icon icon="queen"/>
<font-awesome-layers-text class="gray8" transform="down-2 shrink-8" value="Q" />
</font-awesome-layers>
FAQs
Official Vue component for Font Awesome 6
The npm package @fortawesome/vue-fontawesome receives a total of 170,784 weekly downloads. As such, @fortawesome/vue-fontawesome popularity was classified as popular.
We found that @fortawesome/vue-fontawesome demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers 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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.