• Stars
    star
    110
  • Rank 316,770 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 5 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Module to use Font Awesome icons in Nuxt.js

@nuxtjs/fontawesome

npm version npm downloads Circle CI License

Module to use Font Awesome icons in your Nuxt.js project. Uses vue-fontawesome under the hood

📖 Release Notes

Setup

  • Add dependency using npm to your project
$ yarn add @nuxtjs/fontawesome -D

// or to also add the free icon packs

$ yarn add @nuxtjs/fontawesome @fortawesome/free-solid-svg-icons @fortawesome/free-brands-svg-icons -D
  • Add @nuxtjs/fontawesome to buildModules in your nuxt.config
  • Configure loaded icons/whole sets

Use the 'fontawesome' key:

  // nuxt.config.js
  buildModules: [
    '@nuxtjs/fontawesome',
  ],

  fontawesome: {
    icons: {
      solid: ['faCog', ...],
      ...
    }
  }
}

or include the options in the modules listing

  // nuxt.config.js
  buildModules: [
    ['@nuxtjs/fontawesome', {
      component: 'fa',
      suffix: true,
      proIcons: { // if you have bought the Pro packages
        // list the icons you want to add, not listed icons will be tree-shaked
        solid: [
          'faHome',
          'faHeart'
        ],
        // include all icons. But dont do this.
        regular: true
      }
    }]
  ]

Module options

component

  • Default: FontAwesomeIcon

Change component name. Eg set to fa to use <fa icon="" ... />. Also see suffix

It's strongly recommended to use PascalCase for component names

useLayers

  • Default: true

Boolean to indicate if the layers component should be registered globally. Name of the component will be ${options.component}-layers, fe <fa-layers ... />

useLayersText

  • Default: true

Boolean to indicate if the layers component should be registered globally. Name of the component will be the ${options.component}-layers-text, fe <fa-layers-text ... />

icons

Which icons you will use. FontAwesome currently supports 5 icon styles of which 3 are freely available (partially).

This option is an object with the style names as property and an array with all icon names you wish to use from those styles

  icons: {
    solid: [ 'faHome', ... ],
    regular: [ ... ],
    light: [ ... ],
    duotone: [ ... ],
    brands: [ ...]
  }

Although not recommended, you can use true to include the full icon set:

  icons: {
    solid: true
  }

proIcons

See icons for how to use, but always uses pro imports.

addCss

  • Default: true

If the module should automatically add the fontawesome styles to the global css config. It works by unshifting @fortawesome/fontawesome-svg-core/styles.css onto the nuxt.options.css property.

suffix

  • Default: false

Boolean whether to append -icon to the icon component name. This option exists as the component name option is also used for the layer components and you might not want to add '-icon' to those

  // config
  component: 'Fa',
  suffix: true

  // usage
  <fa-icon />
  <fa-layer />
  // config
  component: 'FaIcon',
  suffix: false

  // usage
  <fa-icon />
  <fa-icon-layers />

imports deprecated

Import icons/whole sets from chosen packages. This is the old configuration and will likely be removed in a future version. Use icons instead

  • Default: [], no icons will be imported here (see below, can be loaded later inside .vue file)
    • set - path to node package for import, like @fortawesome/free-solid-svg-icons
    • icons - array of icons to import ['faAdjust', 'faArchive'].
  imports: [
    {
      set: '@fortawesome/free-solid-svg-icons',
      icons: ['faHome']
    }
  ]

Usage

You can find more details under example folder. Also please see vue-fontawesome for additional reference

  • Ensure you have installed an icon package yarn add @fortawesome/free-solid-svg-icons -D
  • and have added the module configuration to your nuxt.config.js

Default component names are:

  • <font-awesome-icon>
  • <font-awesome-layers>
  • <font-awesome-layers-text>

With component option set, -layers and -layers-text suffixes will be appended (see example below)

  // nuxt.config
  fontawesome: {
    icons: {
      solid: ['faHome'],
      regular: ['faAdjust']
    }
  },
  • Use global icons:
<template>
  <div>
    <font-awesome-icon :icon="['fas', 'adjust']"  />
    <font-awesome-icon icon="dollar-sign"  style="font-size: 30px"/>
    <font-awesome-icon icon="cog"/>

    <font-awesome-layers class="fa-4x">
      <font-awesome-icon icon="circle"/>
      <font-awesome-icon icon="check" transform="shrink-6" :style="{ color: 'white' }"/>
    </font-awesome-layers>

    <font-awesome-layers full-width class="fa-4x">
      <font-awesome-icon icon="calendar"/>
      <font-awesome-layers-text transform="shrink-8 down-3" value="27" class="fa-inverse" />
    </font-awesome-layers>
  </div>
</template>

<script></script>
  • Use locally imported icons
<template>
    <div>
        <fa-layers full-width class="fa-4x">
          <fa :icon="fas.faCircle"/>
          <fa-layers-text transform="shrink-12" value="GALSD" class="fa-inverse" />
        </fa-layers>

        <fa :icon="fas.faAddressBook"  />
        <fa :icon="faGithub" />
    </div>
</template>

<script>
import { fas } from '@fortawesome/free-solid-svg-icons'
import { faGithub } from '@fortawesome/free-brands-svg-icons'

export default {
  computed: {
    fas () {
       return fas // NOT RECOMMENDED
    },
    faGithub () {
       return faGithub
    }
  },
}
</script>

Integrations

Storybook

If you are fan of storybook this might be interesting for you, This module provides a story to list and search available icons of your project. You can see stories under stories directory. If you are using @nuxtjs/storybook you can see the fontawesome stories under Modules section in your storybook. By default Font Awesome story will shows in your storybook, you disable/hide the story using Storybook's modules option

License

MIT License

This module was forked from the (font) awesome module created by Galley Web Development

Copyright (c) Nuxt Community

More Repositories

1

auth-module

Zero-boilerplate authentication support for Nuxt 2
TypeScript
1,926
star
2

legacy-modules

JavaScript
1,285
star
3

express-template

Starter template for Nuxt 2 with Express.
Vue
1,248
star
4

pwa-module

Zero config PWA solution for Nuxt.js
TypeScript
1,236
star
5

axios-module

Secure and easy axios integration for Nuxt 2
JavaScript
1,199
star
6

tailwindcss-module

Tailwind CSS module for Nuxt
TypeScript
1,023
star
7

i18n-module

i18n for Nuxt
JavaScript
959
star
8

color-mode-module

Dark and Light mode with auto detection made easy with Nuxt 🌗
TypeScript
743
star
9

device-module

Nuxt.js module for detecting device type.
TypeScript
735
star
10

composition-api

Composition API hooks for Nuxt 2.
TypeScript
710
star
11

sitemap-module

Sitemap Module for Nuxt 2
JavaScript
688
star
12

typescript-template

Typescript starter for Nuxt 2
Vue
642
star
13

firebase-module

🔥 Easily integrate Firebase into your Nuxt project. 🔥
JavaScript
641
star
14

google-analytics-module

Google Analytics Module for Nuxt 2
JavaScript
638
star
15

vuetify-module

Vuetify Module for Nuxt 2
TypeScript
629
star
16

starter-template

DEPRECATED: use create-nuxt-app instead
Vue
607
star
17

style-resources-module

Style Resources for Nuxt 3
TypeScript
574
star
18

sentry-module

Sentry module for Nuxt 2
TypeScript
500
star
19

dotenv-module

Loads your .env file into your application context
JavaScript
492
star
20

adonuxt-template

[Deprecated] Starter template for Nuxt.js with AdonisJS.
JavaScript
451
star
21

proxy-module

The one-liner node.js http-proxy middleware solution for Nuxt 2 using http-proxy-middleware
TypeScript
408
star
22

router-module

Nuxt 2 module to use router.js instead of pages/ directory.
TypeScript
401
star
23

nuxt-property-decorator

Property decorators for Nuxt (base on vue-property-decorator)
JavaScript
396
star
24

nuxtent-module

Seamlessly use content files in your Nuxt.js sites.
TypeScript
389
star
25

koa-template

Starter template for Nuxt.js with KoaJS.
JavaScript
382
star
26

svg-module

Super simple svg loading module for Nuxt.js
JavaScript
338
star
27

gtm-module

Google Tag Manager Module for Nuxt.js
JavaScript
327
star
28

nuxt7

📱 Full Featured iOS & Android PWA Apps with Nuxt.js and Framework7
TypeScript
324
star
29

redirect-module

No more cumbersome redirects for Nuxt 2!
JavaScript
310
star
30

storybook

Storybook integration with Nuxt.js
TypeScript
293
star
31

router-extras-module

Extra Add-ons For Nuxt 2 Router
JavaScript
279
star
32

universal-storage-module

Universal Storage Utilities for Nuxt 2
TypeScript
276
star
33

strapi-module

Strapi Module for Nuxt
TypeScript
269
star
34

robots-module

NuxtJS module for robots.txt
TypeScript
268
star
35

dayjs-module

Day.js module for your Nuxt 2 project.
TypeScript
261
star
36

google-fonts-module

Google Fonts module for NuxtJS
TypeScript
256
star
37

recaptcha-module

🤖 Simple and easy Google reCAPTCHA integration with Nuxt.js
JavaScript
252
star
38

svg-sprite-module

Optimize SVG files and combine them into sprite
TypeScript
252
star
39

electron-template

Electron starter with nuxt.js
JavaScript
251
star
40

feed-module

Everyone deserves RSS, ATOM and JSON feeds!
JavaScript
227
star
41

google-optimize-module

SSR friendly Google Optimize module for Nuxt.js
JavaScript
215
star
42

amp-module

AMP Module for Nuxt 2
Vue
204
star
43

python-module

Write Nuxt 2 applications using Python! [Experimental]
Vue
201
star
44

moment-module

Efficient Moment.js integration for Nuxt
JavaScript
194
star
45

prismic-module

Easily connect your Nuxt.js application to your content hosted on Prismic
JavaScript
180
star
46

hackernews-nuxt-ts

Typescript Version of HackerNews Nuxt
Vue
174
star
47

nuxt-generate-cluster

Multi-threaded generator command for nuxt.js
JavaScript
153
star
48

google-gtag-module

Enable google gtagjs for NuxtJs
JavaScript
147
star
49

partytown-module

Partytown integration for Nuxt. Run third-party scripts from a web worker.
TypeScript
138
star
50

pwa-template

PWA template for vue-cli based on the starter template
Vue
133
star
51

blog-module

Build your blog with @nuxt
JavaScript
132
star
52

cloudinary-module

Integration of Cloudinary to Nuxt.js
TypeScript
129
star
53

module-template

Starter template for Nuxt.js Modules
JavaScript
127
star
54

sanity-module

Sanity integration for Nuxt
TypeScript
126
star
55

nuxt-logrocket

LogRocket module for Nuxt.js
TypeScript
121
star
56

google-adsense-module

Google AdSense module for Nuxt.js
Vue
117
star
57

nuxt-class-component

ES / TypeScript decorator for class-style Nuxt/Vue components
TypeScript
113
star
58

localforage-module

Localforage module for Nuxt.js
JavaScript
88
star
59

laravel-echo-module

Laravel Echo for Nuxt 2
TypeScript
85
star
60

webpackmonitor-module

Monitor nuxt webpack optimization metrics through the development process using webpackmonitor
JavaScript
83
star
61

eslint-module

ESLint module for Nuxt.js
TypeScript
78
star
62

date-fns-module

Modern JavaScript date utility library - date-fns for Nuxt.js
JavaScript
78
star
63

onesignal-module

OneSignal for Nuxt 2
TypeScript
74
star
64

micro-template

Starter template for Nuxt.js with Δ micro
JavaScript
73
star
65

emotion-module

💖 Emotion module for Nuxt.js
TypeScript
63
star
66

ngrok-module

ngrok exposes your localhost to the world for easy testing and sharing! No need to mess with DNS or deploy just to have others test out your changes
TypeScript
62
star
67

separate-env-module

Tear your variables apart!
JavaScript
57
star
68

harlem-module

Harlem integration for Nuxt. A state management solution for Vue 3.
TypeScript
56
star
69

global-components

Module to register global components for Nuxt.js
JavaScript
55
star
70

netlify-files-module

Nuxt 2 module to create new _headers, _redirects and netlify.toml files for Netlify or to use existing ones
TypeScript
50
star
71

imagemin-module

Automatically optimize (compress) all images used in Nuxt.js
TypeScript
50
star
72

nuxtent-template

Starter template for content heavy sites.
Vue
49
star
73

markdownit-module

Markdownit for Nuxt 2
JavaScript
48
star
74

lunr-module

Full-text search with pre-build indexes for Nuxt.js using lunr.js
JavaScript
47
star
75

mdx-module

MDX module for Nuxt 2
JavaScript
47
star
76

hapi-nuxt

Nuxt.js plugin for Hapi.js
JavaScript
46
star
77

supabase-module

Supabase module for Nuxt.
TypeScript
43
star
78

stylelint-module

Stylelint module for Nuxt.js
JavaScript
42
star
79

html-minifier-module

SSR HTML minification for Nuxt 2 (⚠️ experimental)
JavaScript
40
star
80

snipcart-module

Snipcart integration with for NuxtJS
JavaScript
32
star
81

component-cache-module

JavaScript
31
star
82

critters-module

CSS optimization using critters for Nuxt
JavaScript
30
star
83

dynamic-i18n

Synchronize automatically your translations from a specific provider
JavaScript
23
star
84

guess-module

Guess.js module for Nuxt 2
JavaScript
21
star
85

design-tokens-module

Design tokens module for Nuxt
TypeScript
20
star
86

applicationinsights-module

Application Insights module for Nuxt 2
JavaScript
18
star
87

observable-module

Nuxt.js module that injects a lightweight, Vue.observable()-based $state into the context
JavaScript
17
star
88

ackee-module

Nuxt 2 module for Ackee analytics
JavaScript
14
star
89

yandex-metrika-module

⚠️ Yandex Collects Your Personal Data! https://en.wikipedia.org/wiki/Yandex#Security
JavaScript
12
star
90

module-template-rollup

Starter template for Nuxt.js Modules with rollup
JavaScript
11
star
91

module-builder

🏗️ Nuxt Standard Module Builder (Depricated)
JavaScript
11
star
92

nuxt-helper-json

Vetur integration information for Nuxt.js
9
star
93

webpack-profile-module

Nuxt module to display webpack build progress steps with core ProgressPlugin
JavaScript
8
star
94

nuxt-event-trace

JavaScript
5
star
95

motd

Your source for Nuxt 2 tips
JavaScript
4
star
96

speedcurve-module

Speedcurve LUX integration for Nuxt 2
JavaScript
2
star
97

package-discovery

Package discovery automatically (⚠️ experimental)
JavaScript
2
star