vue fontawesome icons code example

Example 1: installing fontawesome vue project

//install fontawesome icons
npm install --save-dev @fortawesome/fontawesome-free

//inside main.js add
import '@fortawesome/fontawesome-free/css/all.css'     <------
import '@fortawesome/fontawesome-free/js/all.js'    <------
.
.
.
new Vue({  router,  store,  render: h => h(App),}).$mount('#app')


// you can now use the icons anywhere in your project with the <i>
   <i class="fab fa-2x fa-facebook"></i>
   <i class="fab fa-2x fa-twitter"></i>
   <i class="fab fa-2x fa-instagram"></i>

Example 2: vue font awesome icons

$ npm i --save @fortawesome/fontawesome-svg-core
$ npm i --save @fortawesome/free-solid-svg-icons

Example 3: vue font awesome icons

<!-- The solid style is implicit -->
<font-awesome-icon icon="user-secret" />

<!-- It's better to be explicit -->
<!-- Don't forget to bind the property with ":" (we forget all the time!) -->
<font-awesome-icon :icon="['fas', 'user-secret']" />

Example 4: vue font awesome icons

import { library } from '@fortawesome/fontawesome-svg-core'
import { faUserSecret } from '@fortawesome/free-solid-svg-icons'

library.add(faUserSecret)

Example 5: vue font awesome icons

<template>
  <div id="app">
    <font-awesome-icon icon="user-secret" />
  </div>
</template>

<script>
export default {
  name: 'App'
}
</script>