Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

oh-vue-icons

Renovamen21.4kMIT1.0.0-rc3TypeScript support: included

Include inline SVG icons from different popular icon packs in Vue 2 & 3 easily.

icons, vue, vue3, font awesome, remix icon, bootstrap icons, line awesome, octions, simple icons, heroicons, material design icons, ionicons

readme

Oh, Vue Icons!

npm downloads license

English | 中文说明

A Vue component for including inline SVG icons from different popular icon packs easily.

 

Features

  • Works for both Vue 2 & 3
  • Supports tree-shaking: only import the icons you want
  • 30000+ icons from 20 popular icon packs, see here

 

Supported Icon Packs

Now the following 20 icon packs are supported:

Icon Pack Prefix License Counts
academicons ai SIL OFL 1.1 147
Bootstrap Icons bi MIT 1522
CoreUI Icons Free (Colorful) co CC BY 4.0 License 1575
Cryptocurrency Icons (Colorful) ci CC0 1.0 Universal 942
Font Awesome 5 Free fa CC BY 4.0 1610
Flat Color Icons (Colorful) fc MIT / Good Boy 329
Flag Icon (Colorful) fi MIT 530
gameicons gi CC BY 3.0 4052
Heroicons hi MIT 460
Ionicons io MIT 1332
Line Awesome la MIT / Good Boy 1544
Material Design icons md Apache 2.0 10337
Octicons oi MIT 250
Pokemon Icons (Colorful) pi CC BY 4.0 1453
PrimeIcons pr MIT 238
Pixelarticons px MIT 460
Remix Icon ri Apache 2.0 2271
Simple Icons si CC0 1.0 Universal 2159
VSCode Icons (Colorful) vi CC BY-SA 4.0 1098
Weather Icons wi SIL OFL 1.1 219

 

Documentation

Search for icons and view the documentation here.

 

Installation

yarn add oh-vue-icons
# or
npm install oh-vue-icons

For Vue 2, you'll also need @vue/composition-api:

yarn add @vue/composition-api -D

Or if you are using Nuxt 2, you'll need @nuxtjs/composition-api instead:

yarn add @nuxtjs/composition-api -D

then add @nuxtjs/composition-api/module to the buildModules option in your nuxt.config.js, see here for details.

 

Import

Global Import

Import oh-vue-icons and install it into Vue in main.js. You can only import the icons you need to reduce the bundle size.

From v1.x, this library works for both Vue 2 & 3 within a single package.

Vue 3

// main.js
import { createApp } from "vue";
import App from "./App.vue";

import { OhVueIcon, addIcons } from "oh-vue-icons";
import { FaFlag, RiZhihuFill } from "oh-vue-icons/icons";

addIcons(FaFlag, RiZhihuFill);

const app = createApp(App);
app.component("v-icon", OhVueIcon);
app.mount("#app");

If you don't care about the bundle size and want to import a whole icon pack, you may should:

// main.js
// import Font Awesome
import * as FaIcons from "oh-vue-icons/icons/fa";

const Fa = Object.values({ ...FaIcons });
addIcons(...Fa);

Vue 2

// main.js
import Vue from "vue";
import App from "./App.vue";

import { OhVueIcon, addIcons } from "oh-vue-icons";
import { FaFlag, RiZhihuFill } from "oh-vue-icons/icons";

addIcons(FaFlag, RiZhihuFill);

Vue.component("v-icon", OhVueIcon);

new Vue({
  render: h => h(App)
}).$mount("#app");

 

Local Import

import OhVueIcon from "oh-vue-icons";

export default {
  components: {
    "v-icon": OhVueIcon
  }
};

 

Usage

The icon names should be passed using kebab-case.

<template>
  <div>
    <v-icon name="fa-flag" />
    <v-icon name="ri-zhihu-fill" />
  </div>
</template>

For Font Awesome 5 icons, icons from regular pack have name prop values like fa-regular-flag. Icons from solid and brands pack have name prop values like fa-beer and fa-github.

See the documentation for more about the usage.

 

Props

Name Description Type Accepted Values Default value
scale Icon size number / 1
animation Type of animation string wrench / ring / pulse / spin / spin-pulse / flash / float /
speed Animation speed string slow / fast /
hover Enable animation only when being hovered boolean true / false false
flip Used to flip icon string vertical / horizontal / both /
fill Fill color of icon string HEX color code or color name currentColor
label Icon lable string / /
title Icon title string / /
inverse Make icon color white? boolean true / false false

Some examples could be found in the documentation.

 

Nuxt

When using Nuxt, you need to register oh-vue-icons as a plugin following Nuxt's documentation.

It should be noted that, oh-vue-icons should be added to the build.transpile option in your nuxt.config.js (see here for details):

export default {
  // ...
  build: {
    transpile: ["oh-vue-icons"]
  }
}

To render the icon component only on client-side, you may need to wrap it in a <client-only> tag:

<template>
  <div>
    <client-only>
      <v-icon name="fa-flag" />
      <v-icon name="ri-zhihu-fill" />
    </client-only>
  </div>
</template>

 

Vite

When using Vite, it is suggested to exclude oh-vue-icons from pre-bundling (see #20 for details):

// vite.config.js

export default {
  // ...
  optimizeDeps: {
    exclude: ["oh-vue-icons/icons"]
  }
}

When using Vite's Server-Side Rendering (SSR) support (VuePress, Vite SSG, etc.), oh-vue-icons should be added to the ssr.noExternal option (see here for details):

// vite.config.js

export default {
  // ...
  ssr: {
    noExternal: ["oh-vue-icons"]
  }
}

 

Contributing

Contributions are welcomed, see the contribution guides.

 

Acknowledgements

 

License

This project is MIT licensed. Icons are taken from other projects, so check the license of each accordingly.

changelog

Change Log

v1.0.0-rc2 (2022-01-27)

Features

1.0.0-rc1 (2021-10-14)

BREAKING CHANGES

  • import paths have changed:

    Vue 3:

    - import OhVueIcon from "oh-vue-icons/dist/v3/icon.es";
    + import { OhVueIcon, addIcons } from "oh-vue-icons";
    
    - OhVueIcon.add(FaFlag)
    + addIcons(FaFlag)

    Vue 2:

    - import OhVueIcon from "oh-vue-icons";
    + import { OhVueIcon, addIcons } from "oh-vue-icons";
    
    - OhVueIcon.add(FaFlag)
    + addIcons(FaFlag)
  • @vue/composition-api is needed for Vue 2, @nuxtjs/composition-api is needed for Nuxt 2.

Features

0.4.7 (2021-08-02)

Features

0.4.6 (2021-07-25)

Features

0.4.5 (2021-07-18)

Bug Fixes

0.4.4 (2021-07-11)

This version has been DEPRECATED (see #15), use v0.4.5 or above instead.

Features

0.4.3 (2021-05-08)

Features

0.4.2 (2021-04-14)

Features

0.4.1 (2021-03-29)

BREAKING CHANGES

  • expand data argument to remove need of array whem import icons (c32a79b) (#10)
  • use rollup to bundle the component in esm format (4a31c95) (#9)
  • import paths have changed:

    Icons:

    - OhVueIcon.add([FaFlag, RiZhihuFill]);
    + OhVueIcon.add(FaFlag, RiZhihuFill);

    Vue 3:

    - import OhVueIcon from "oh-vue-icons/dist/v3/icon.umd.min";
    + import OhVueIcon from "oh-vue-icons/dist/v3/icon.es";

0.3.1 (2021-03-26)

Features

0.3.0 (2021-03-24)

Features

BREAKING CHANGES

  • import paths have changed:

    Vue 2:

    - import OhVueIcon from "oh-vue-icons/components/icon";
    + import OhVueIcon from "oh-vue-icons";

    Vue 2 SSR:

    + import OhVueIcon from "oh-vue-icons/dist-css/v2/icon.umd.min";
    + import 'oh-vue-icons/dist-css/v2/icon.css'

    Vue 3:

    - import OhVueIcon from "oh-vue-icons/components/icon-v3";
    + import OhVueIcon from "oh-vue-icons/dist/v3/icon.umd.min";

    Vue 3 SSR:

    + import OhVueIcon from "oh-vue-icons/dist-css/v3/icon.umd.min";
    + import 'oh-vue-icons/dist-css/v3/icon.css'

0.2.2 (2021-03-22)

Features

0.2.1 (2021-03-14)

BREAKING CHANGES

  • support Vue 3 🎉 (d58e037)
  • import path for Vue 2 has changed:

    - import OhVueIcon from "oh-vue-icons/components/Icon";
    + import OhVueIcon from "oh-vue-icons/components/icon";

Features

0.1.11 (2021-02-27)

Bug Fixes

  • remove core-js from dependencies (#3) (0213f03)

0.1.10 (2021-02-25)

Features

0.1.9 (2021-02-13)

Features

0.1.8 (2021-02-02)

Features

  • iconpack: add Octicons (b381719)
  • animation: support adjusting animation speed, add flash animation (e8ecf8f)

0.1.7 (2021-01-05)

Bug Fixes

  • fix tree shaking problems (which occured due to the code sructure change in v0.1.5) (3507656)

Features

0.1.6 (2021-01-03)

Features

Chore

  • change the prefix of gameicons to 'gi' (287852b)

0.1.5 (2020-12-25)

Features

BREAKING CHANGES

  • change the way of importing icons (40d37d2)

0.1.2 (2020-12-06)

Features

  • resize some of the icons for better and more consistent user experience (6caf2e2)

0.1.1 (2020-12-06)

Bug Fixes

  • upgrade some packages to generate svgs correctly (0e37e60)

Features

  • support importing a whole given icon pack (cb3e137)

0.1.0 (2020-12-04)

Features