Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nuxt 3 font awesome

/**
 * According to the official Font Awesome docs, it's now
 * possible to add Font Awesome to Nuxt 3!
 */ 

// ===
// STEP 1: Install @fortawesome/vue-fontawesome@latest-3 with npm or yarn
// ===

// npm i --save @fortawesome/vue-fontawesome@latest-3 @fortawesome/fontawesome-svg-core @fortawesome/vue-fontawesome
// yarn add @fortawesome/vue-fontawesome@latest-3 @fortawesome/fontawesome-svg-core @fortawesome/vue-fontawesome

// ===
// STEP 2: Create a `plugins/fontawesome.js` file and copy paste this
// ===
import { library, config } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { fas } from '@fortawesome/free-solid-svg-icons'
import { fab } from '@fortawesome/free-brand-svg-icons'

// This is important, we are going to let Nuxt worry about the CSS
config.autoAddCss = false

// You can add your icons directly in this plugin. See other examples for how you
// can add other styles or just individual icons.
library.add(fas)
library.add(fab)

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.component('font-awesome-icon', FontAwesomeIcon, {})
})

// ===
// STEP 3: Add the Font Awesome CSS to your Nuxt config
// Note: you don't have to specify plugin as you would previously in Nuxt 2.
// ===

// nuxt.config.ts
export default defineNuxtConfig({
  // ...
  css: [
    '@fortawesome/fontawesome-svg-core/styles.css'
  ]
  // ...
})

// And that's pretty much it! You can use use FA to your Nuxt 3 project!
Comment

PREVIOUS NEXT
Code Example
Javascript :: express send pdf to view 
Javascript :: line break in js 
Javascript :: regex date checker 
Javascript :: add and remove class in jquery 
Javascript :: react get route params 
Javascript :: Using json_encode() function to convert an Array to a string 
Javascript :: get channel object using its name discod.js 
Javascript :: use css child selector inside js 
Javascript :: Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec. 
Javascript :: Modal Dialogs in React 
Javascript :: deleteicon material ui improt 
Javascript :: js array find 
Javascript :: react controlled input 
Javascript :: JavaScript then() method 
Javascript :: inheritance in class in js 
Javascript :: js promises 
Javascript :: call a self executing function javascript 
Javascript :: monaco editor get content 
Javascript :: round 2 decimales js 
Javascript :: how to use buffer in angular by using browserify 
Javascript :: Object.Values () javascript 
Javascript :: how to append response header in node 
Javascript :: node .env file example 
Javascript :: proper to mixed fraction in javascript 
Javascript :: validateDOMNesting(...): <div cannot appear as a descendant of <p. 
Javascript :: pause console debugger in react 
Javascript :: get data from excel using vue js 
Javascript :: odd number is javascript 
Javascript :: import react js video player 
Javascript :: else return 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =