2020-08-28 17:58:33 +08:00
# IconPark Icons
> Vue Icons for IconPark
## Introduction
### Features
2021-01-17 11:31:22 +08:00
* Provide more than 2000 icons
2020-08-28 17:58:33 +08:00
* Provide 4 themes:
* outline
* filled
* two-tone
* multi-color
### More
2020-09-03 21:03:21 +08:00
Please visit [IconPark Website ](http://iconpark.bytedance.com )
2020-08-28 17:58:33 +08:00
* Copy SVG
* Copy React Icon component
* Copy Vue Icon component
* Download PNG
* Download SVG
## Getting Started
### Install
2020-08-27 17:02:57 +08:00
```
npm install @icon -park/vue --save
```
2020-08-28 17:58:33 +08:00
### Include Component
Import an icon from `@icon-park/vue` at the top of a component and then use it in the template tag:
2020-08-27 17:02:57 +08:00
``` vue
< template >
2020-09-30 00:26:59 +08:00
< home theme = "filled" / >
2020-08-27 17:02:57 +08:00
< / template >
< script >
import {Home} from '@icon -park/vue';
export default {
components: {
Home
}
}
< / script >
```
2020-08-28 17:58:33 +08:00
If you don't want to refer to it, you can install icons globally.
2020-08-27 17:02:57 +08:00
```typescript
2020-12-27 01:16:00 +08:00
import {install} from '@icon -park/vue/es/all';
2020-08-27 17:02:57 +08:00
import Vue from 'vue';
// Install
2020-12-27 01:16:00 +08:00
install(Vue); // use default prefix 'icon', eg: icon is People, name is icon-people.
install(Vue, 'i'); // use custom prefix 'i', eg: icon is People, name is i-people.
2020-08-27 17:02:57 +08:00
```
### Style Sheet
2020-08-28 17:58:33 +08:00
Import the icon style:
2020-08-27 17:02:57 +08:00
```typescript
import '@icon -park/vue/styles/index.css';
```
2020-08-28 17:58:33 +08:00
### Global Config
You can use the 'provide' property provided by `Vue` to set the global configuration.
2020-08-27 17:02:57 +08:00
```html
< template >
< div >
< home / >
< / div >
< / template >
< script lang = "ts" >
2020-09-30 00:26:59 +08:00
import {DEFAULT_ICON_CONFIGS} from '@icon -park/vue'
2020-08-27 17:02:57 +08:00
import {Home} from '@icon -park/vue';
const IconConfig = {...DEFAULT_ICON_CONFIGS, prefix: 'icon'}
export default {
name: 'App',
provide () {
return {
ICON_CONFIGS: IconConfig
}
},
components: {
Home
}
};
< / script >
```
2020-08-28 17:58:33 +08:00
### Import on Demand
2020-08-27 17:02:57 +08:00
2020-08-28 17:58:33 +08:00
You can use [babel-plugin-import ](https://github.com/ant-design/babel-plugin-import ) to import icons on demand.
2020-08-27 17:02:57 +08:00
2020-08-28 17:58:33 +08:00
Set config like this:
2020-08-27 17:02:57 +08:00
```json
{
"plugins": [
[
"import",
{
"libraryName": "@icon -park/vue",
"libraryDirectory": "es/icons",
2020-08-27 17:08:18 +08:00
"camel2DashComponentName": false
2020-08-27 17:02:57 +08:00
}
]
]
}
```
2020-08-28 17:58:33 +08:00
### Icon Component
We recommend loading icons on demand, because this can greatly reduce the volume of compiled code。
However, in some scenarios similar to remote loading menus, direct reference to all icons can reduce the development cost.
2020-08-27 17:02:57 +08:00
2020-08-28 17:58:33 +08:00
Usage:
2020-08-27 17:02:57 +08:00
``` vue
< template >
2021-02-15 20:21:59 +08:00
< icon-park type = "AddText" theme = "filled" / >
< icon-park type = "add-text" theme = "filled" / >
2020-08-27 17:02:57 +08:00
< / template >
< script >
2020-11-26 17:27:21 +08:00
import {IconPark} from '@icon -park/vue/es/all';
2020-08-27 17:02:57 +08:00
export default {
components: {
IconPark
}
}
< / script >
```
2021-01-17 11:31:22 +08:00
### Embed IconPark in your project
If you need to use additional information such as icon name, author, category, label and creation time, you can use the `icons.json` file located in the root directory of each NPM.
2020-08-27 17:02:57 +08:00
2020-08-28 17:58:33 +08:00
## Props
| prop | description | type | default | note |
2020-08-27 17:02:57 +08:00
| ---------- | --- | --- | --- | --- |
2020-08-28 17:58:33 +08:00
| theme | Theme of the icons. | 'outline' & #124 ; 'filled' & #124 ; 'two-tone' & #124 ; 'multi-color' | 'outline' |
| size | The width/height of the icon | number & #124 ; string | '1em' |
| spin | Rotate icon with animation | boolean | false |
| fill | Colors of theme | string & #124 ; string[] | 'currentColor' |
| strokeLinecap | the stroke-linecap prop of svg element | 'butt' & #124 ; 'round' & #124 ; 'square' | 'round' |
| strokeLinejoin | the stroke-linejoin prop of svg element | 'miter' & #124 ; 'round' & #124 ; 'bevel' | 'round' |
| strokeWidth | the stroke-width prop of svg element | number | 4 |