• Stars
    star
    205
  • Rank 191,264 (Top 4 %)
  • Language
    JavaScript
  • License
    Other
  • Created almost 4 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

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

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 149
Bootstrap Icons bi MIT 1668
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 10537
Octicons oi MIT 259
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 2233
VSCode Icons (Colorful) vi CC BY-SA 4.0 1125
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.

More Repositories

1

playground-macos

My portfolio website simulating macOS's GUI, developed with React and UnoCSS.
TypeScript
2,900
star
2

Speech-Emotion-Recognition

Speech emotion recognition implemented in Keras (LSTM, CNN, SVM, MLP) | 语音情感识别
Python
648
star
3

vuepress-theme-gungnir

A blog theme for VuePress 2.
TypeScript
314
star
4

Speech-and-Text

Speech to text (PocketSphinx, Iflytex API, Baidu API) and text to speech (pyttsx3) | 语音转文字(PocketSphinx、百度 API、科大讯飞 API)和文字转语音(pyttsx3)
Python
247
star
5

Text-Classification

PyTorch implementation of some text classification models (HAN, fastText, BiLSTM-Attention, TextCNN, Transformer) | 文本分类
Python
126
star
6

pcalg-py

Implement PC algorithm in Python | PC 算法的 Python 实现
Python
88
star
7

Fishmail

奇怪的摸鱼工具增加了:装作在 Gmail 上查邮件的样子看知乎摸鱼,从而降低我上班摸鱼时的不安全感
Vue
65
star
8

Just-a-Cube

A rubik's cube solver | 魔方还原(层先法 + Two-phase)
JavaScript
54
star
9

oh-my-cv

Write your curriculum vitae in Markdown online.
TypeScript
51
star
10

blog.zxh.io

My blog 🧐, powered by VuePress 2, themed by Gungnir.
CSS
36
star
11

flint

A toy deep learning framework implemented in pure Numpy from scratch. Aka homemade PyTorch lol.
Python
30
star
12

jekyll-theme-gungnir

A blog theme for Jekyll.
SCSS
17
star
13

what-if

My messy notebook, built with VuePress 2.
TypeScript
17
star
14

renovamen.github.io

My personal website 🤔
TypeScript
14
star
15

Legend-of-Zeld

Spring 2018 User Interface Interaction - A web page for "The Legend of Zelda: Breath of the Wild" | 塞尔达传说:荒野之息
CSS
12
star
16

Operating-Systems

Spring 2018 Operating Systems - Assignments (Elevator Scheduling, Memory Management and File Management) | 操作系统课程项目(电梯调度,内存管理,文件管理)
Java
11
star
17

KG-Application-Papers

Paper list about application of Knowledge Graph | 知识图谱的应用相关论文
10
star
18

midgard

Hey adventurer! Why not help me with retrieving my curriculum vitae fragments back! | 来帮我找简历吗勇士!
TypeScript
10
star
19

Image-Captioning

PyTorch re-implementation of some papers on image captioning | 图像描述
Python
7
star
20

metallic

A clean, lightweight and modularized PyTorch meta-learning library.
Python
7
star
21

wordle-helper

Help you solve the Wordle puzzles when your vocabulary failes you.
TypeScript
5
star
22

Ratom

Spring 2019 Introduction to Cybersecurity - A simple cross platform rat (remote access trojan)
Python
4
star
23

Gomoku

Fall 2016 C Programming - A Gomoku AI based on Minimax Algorithm with Alpha-beta pruning | 基于极大极小值搜索 + Alpha-beta 剪枝的五子棋人工智障
C
3
star
24

AntiFood

深夜放毒反击系统(基于酷 Q 和 NoneBot)
Python
3
star
25

OI-ACM

My solutions for OI / ACM problems - 退役蒟蒻的人生回顾
C++
3
star
26

Just-Movies

Spring 2019 Web System and Technology - Assigment: Assignment: A movie web app using Django and Vue | Django + Vue 实现的电影 Web 应用
Vue
3
star
27

gitbook-plugin-katex

Math typesetting using KaTex into Gitbook. Update Katex to the latest version (0.11.1) and support single '$' for inline math.
JavaScript
2
star
28

HUAJI_OS

Spring 2018 Operating System - Final Project | 操作系统课程设计,修改了 ORANGES 的源码
C
2
star
29

torchop

A collection of some attention / convolution operators implemented using PyTorch.
Python
2
star
30

Galaxy-Voyager

Spring 2019 Web System and Technology - Final Project: A game
JavaScript
2
star
31

alkaid

PyTorch reinforcement learning toolbox.
Python
1
star
32

Stupid-Torch

一个沙雕安卓手电筒 app,在有光的地方亮,没有光的地方绝对不亮
Java
1
star
33

Renovamen

1
star
34

Just-a-Cat

Fall 2018 SOA and Web Services - Individual Assignment: An Android app integrating some Web APIs
Java
1
star
35

Byzantine

Implement the Om(n, m) algorithm for solving the Byzantine generals problem | 拜占庭口头消息算法的 Python 实现
Python
1
star
36

StockBot

A chatbot based on Rasa NLU aims to provide stock and weather information implemented by Python | 基于 Rasa NLU 的提供股票和天气信息的聊天机器人
Jupyter Notebook
1
star