Font Awesome with VueJS 3

Sabbir Sobhani - May 22 '21 - - Dev Community

version 5

Font Awesome is a great tool for working with various of icons. It is the most popular and widely using icon toolkit. In a VueJS 3 CLI project you can easily add Font Awesome library by following these easy steps:

install fontawesome packeges from npm

install all of them one by one

npm i --save @fortawesome/fontawesome-svg-core
npm i --save @fortawesome/free-solid-svg-icons
npm i --save @fortawesome/free-brands-svg-icons
npm i --save @fortawesome/free-regular-svg-icons
npm i --save @fortawesome/vue-fontawesome
npm i --save @fortawesome/vue-fontawesome@prerelease
Enter fullscreen mode Exit fullscreen mode

5 no is for Vue version 3 only
6 no is for Vue 3++ version, also work with Vite

install 5 or 6, not both

import in main.js

You can find main.js inside your vuejs 3 project, /src folder.

//vue-app/src/main.js
import { library } from "@fortawesome/fontawesome-svg-core";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { fas } from '@fortawesome/free-solid-svg-icons'
library.add(fas);
import { fab } from '@fortawesome/free-brands-svg-icons';
library.add(fab);
import { far } from '@fortawesome/free-regular-svg-icons';
library.add(far);
import { dom } from "@fortawesome/fontawesome-svg-core";
dom.watch();

const app = createApp(App);

app.component("font-awesome-icon", FontAwesomeIcon);

// add necessary dependencies...

app.mount("#app");
Enter fullscreen mode Exit fullscreen mode

Thats it! now you can use font awesome icon in your VueJS 3 project!

<i class="fad fa-laugh-wink"></i>
Enter fullscreen mode Exit fullscreen mode

if there any problem popup, don't forget to ask me!

Follow me on Twitter sabbirsobhani

Buy Me a Coffee 🙏:
If this article helped you a bit and you'd like to support my work, feel free to buy me a coffee: https://buymeacoffee.com/sobhani ☕️ Thanks for keeping me motivated!

Note: This article was originally Posted on May 22, 2021. While the core concepts discussed here remain relevant, please be aware that the technology landscape is constantly evolving. Libraries, frameworks, and best practices may have changed since this article was written. For the most up-to-date information, consider checking the latest documentation or resources.

. . . . . . . . . .
Terabox Video Player