README.md 3.1 KB
Newer Older
1
2
3
4
5
6
# IconPark Icons
> Vue Icons for IconPark

## Introduction

### Features
7
* Provide more than 1200 icons
8
9
10
11
12
13
14
* Provide 4 themes:
    * outline
    * filled
    * two-tone
    * multi-color

### More
15
Please visit [IconPark Website](http://iconpark.bytedance.com)
16
17
18
19
20
21
22
23
* Copy SVG
* Copy React Icon component
* Copy Vue Icon component
* Download PNG
* Download SVG

## Getting Started
### Install
24
25
26
27
28

```
npm install @icon-park/vue --save
```

29
30
### Include Component
Import an icon from `@icon-park/vue`at the top of a component and then use it in the template tag:
31
32
33

``` vue
<template>
34
<home theme="filled"/>
35
36
37
38
39
40
41
42
43
44
45
46
</template>
<script>
import {Home} from '@icon-park/vue';

export default {
    components: {
        Home
    }
}
</script>
```

47
If you don't want to refer to it, you can install icons globally.
48
49
50
51
52
53
54
55
56
57
58
59
60

```typescript
import * as icons from '@icon-park/vue';
import Vue from 'vue';

// Install
Object.values(icons).forEach(icon => {
    Vue.install(icon.name, icon);
});
```

### Style Sheet

61
Import the icon style:
62
63
64
65
66

```typescript
import '@icon-park/vue/styles/index.css';
```

67
68
### Global Config
You can use the 'provide' property provided by `Vue` to set the global configuration.
69
70
71
72
73
74
75
76

```html
<template>
<div>
<home/>
</div>
</template>
<script lang="ts">
77
import {DEFAULT_ICON_CONFIGS} from '@icon-park/vue'
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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>

```

97
### Import on Demand
98

99
You can use [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) to import icons on demand.
100

101
Set config like this:
102
103
104
105
106
107
108
109
```json
{
    "plugins": [
        [
            "import",
            {
                "libraryName": "@icon-park/vue",
                "libraryDirectory": "es/icons",
110
                "camel2DashComponentName": false 
111
112
113
114
115
116
            }
        ]
    ]
}
```

117
118
119
### 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.
120

121
Usage:
122
123
124
125


``` vue
<template>
126
<icon-park type="home" theme="filled"/>
127
128
</template>
<script>
AppleMonkey2019's avatar
AppleMonkey2019 已提交
129
import {IconPark} from '@icon-park/vue/es/all';
130
131
132
133
134
135
136
137
138

export default {
    components: {
        IconPark
    }
}
</script>
```

139
140
141

## Props
|    prop	 | description  | type  | default | note |
142
| ---------- | --- | --- | --- | --- |
143
144
145
146
147
148
149
150
| 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 |