FontAwesome Vue.js Component

Nov 29, 2017

NOTE: Refer to latest guide for FontAwesome 5.1.x.

vue-fontawesome is the official Font Awesome 5 Vue component.

Installation

npm install @fortawesome/fontawesome --savenpm install @fortawesome/fontawesome-free-solid --savenpm install @fortawesome/vue-fontawesome --save

Sample 1

Import icon at main.js.

import { faUser } from '@fortawesome/fontawesome-free-solid'import fontawesome from '@fortawesome/fontawesome'fontawesome.library.add(faUser)

Component.

<template>
  <div>
    <font-awesome-icon :icon="['fas', 'user']" />
  </div>
</template>

<script>
import FontAwesomeIcon from '@fortawesome/vue-fontawesome'

export default {
  name: 'Sample',
  components: {
    FontAwesomeIcon
  }
}
</script>

Sample 2

Send icon as computed props/data.

<template>
  <div>
    <font-awesome-icon :icon="icon" />
  </div>
</template>

<script>
import FontAwesomeIcon from '@fortawesome/vue-fontawesome'
import { faUser } from '@fortawesome/fontawesome-free-solid'

export default {
  name: 'Sample',
  computed: {
    icon () {
      return faUser
    }
  },
  components: {
    FontAwesomeIcon
  }
}
</script>

There are some advance feature like animation, size, rotation, refer to https://github.com/FortAwesome/vue-fontawesome

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.