项目作者: Cweili

项目描述 :
Tiny FontAwesome 5 component for Vue.js.
高级语言: HTML
项目地址: git://github.com/Cweili/vue-fa.git
创建时间: 2018-02-07T04:23:42Z
项目社区:https://github.com/Cweili/vue-fa

开源协议:MIT License

下载


vue-fa

npm
bundle size
npm downloads
license

github
build
coverage

Tiny FontAwesome component for Vue.js.

  • FontAwesome version 5 and 6
  • FontAwesome svg icons
  • Tree-shakable, only import used icons
  • No CSS file required
  • FontAwesome layering
  • FontAwesome duotone icons

Documents and examples.

Installation

Notice: vue-fa >= 3.x is based on Vue.js 3.x.

  1. npm install vue-fa --save

Old versions:

vue-fa@2 => vue@2 [Documents]

npm install vue-fa@2

Install FontAwesome icons via [official packages][fontawesome-npm], for example:

  1. npm install @fortawesome/free-solid-svg-icons

Usage

  1. <template>
  2. <div>
  3. <Fa :icon="faFlag"></Fa>
  4. </div>
  5. </template>
  6. <script>
  7. import Fa from 'vue-fa'
  8. import { faFlag } from '@fortawesome/free-solid-svg-icons'
  9. export default {
  10. components: {
  11. Fa
  12. },
  13. setup() {
  14. return {
  15. faFlag
  16. }
  17. }
  18. }
  19. </script>

Properties

  1. <Fa
  2. :icon="faFlag"
  3. size="2x"
  4. color="#ff0000"
  5. fw
  6. pull="left"
  7. :scale="1.2"
  8. :translateX="0.2"
  9. :translateY="0.2"
  10. flip="horizontal"
  11. :rotate="90"
  12. spin
  13. pulse
  14. ></Fa>
  • icon: icon from FontAwesome packages, for example: @fortawesome/free-solid-svg-icons
  • size: string values xs, sm, lg or 2x, 3x, 4x, …, ${number}x
  • color: string icon color, default currentColor
  • fw: boolean fixed width
  • pull: string values left, right
  • scale: number | string transform scale, unit is em, default 1
  • translateX: number | string transform position X, unit is em, default 0
  • translateY: number | string transform position Y, unit is em, default 0
  • flip: string values horizontal, vertical, both
  • rotate: number | string values 90, 180, 270, 30, -30
  • spin: boolean spin icons
  • pulse: boolean pulse spin icons

Layering & Text

  1. import Fa, {
  2. FaLayers,
  3. FaLayersText,
  4. } from 'vue-fa';
  1. <FaLayers
  2. size="4x"
  3. pull="left"
  4. >
  5. <Fa :icon="faCertificate" ></Fa>
  6. <FaLayersText
  7. :scale="0.25"
  8. :rotate="-30"
  9. color="white"
  10. style="font-weight: 900"
  11. >
  12. NEW
  13. </FaLayersText>
  14. </FaLayers>

FaLayers Properties

  • size: string values xs, sm, lg or 2x, 3x, 4x, …, ${number}x
  • pull: string values left, right

FaLayersText Properties

  • size: string values xs, sm, lg or 2x, 3x, 4x, …, ${number}x
  • color: string icon color, default currentColor
  • scale: number | string transform scale, unit is em, default 1
  • translateX: number | string transform position X, unit is em, default 0
  • translateY: number | string transform position Y, unit is em, default 0
  • flip: string values horizontal, vertical, both
  • rotate: number | string values 90, 180, 270, 30, -30

Duotone Icons

  1. import { faFlag } from '@fortawesome/pro-duotone-svg-icons'
  1. <Fa
  2. :icon="faFlag"
  3. primary-color="red"
  4. secondary-color="#000000"
  5. :primary-opacity="0.8"
  6. :secondary-opacity="0.6"
  7. swap-opacity
  8. ></Fa>

Duotone Icons Theme

  1. <script>
  2. import Fa from 'vue-fa'
  3. import { faFlag } from '@fortawesome/pro-duotone-svg-icons'
  4. const theme = {
  5. primaryColor: 'red',
  6. secondaryColor: '#000000',
  7. primaryOpacity: 0.8,
  8. secondaryOpacity: 0.6,
  9. }
  10. </script>
  11. <Fa
  12. icon={faFlag}
  13. v-bind="theme"
  14. ></Fa>