larbi jirari
1 min readApr 19, 2019

Font-awesome (Fortawesome) in class using vue

introduction :

Font-wesome can be used in vue as mentioned in the documentation of font-awesome and github

  • install
  npm i --save @fortawesome/fontawesome-svg-core 
npm i --save @fortawesome/free-solid-svg-icons
npm i --save @fortawesome/vue-fontawesome

Vue version: 2.6.10

Fort-awesome version: 0.1.6

  • Code
import Vue from 'vue'
import App from './App'
//---NECESSARY IMPORT---
import { library, dom } from '@fortawesome/fontawesome-svg-core'
import { fas } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
//----------------------
//add fas to library, now fonts can be used in any component under App
library.add(fas)
//registered globally used as a component <font-awesome-icon icon="check" />
Vue.component('font-awesome-icon', FontAwesomeIcon)
// to support class in components <i class='fas fa-check'></i>
dom.watch()

/* eslint-disable no-new */
new Vue({
el: '#app',
components: { App },
template: '<App/>'
})

working example (codesandbox)

read more on Font-awesome website