Vue3 Icons for IconPark
Please visit IconPark Website
npm install @icon-park/vue-next --save
Import an icon from @icon-park/vue-next
at the top of a component and then use it in the template tag:
<template>
<home theme="filled"/>
</template>
<script>
import {Home} from '@icon-park/vue-next';
export default {
components: {
Home
}
}
</script>
If you donāt want to refer to it, you can install icons globally.
import {install} from '@icon-park/vue-next/es/all';
import {createApp} from 'vue';
const app = createApp({});
// Install
install(app); // use default prefix 'icon', eg: icon is People, name is icon-people.
install(app, 'i'); // use custom prefix 'i', eg: icon is People, name is i-people.
app.mount('#app');
Import the icon style:
import '@icon-park/vue-next/styles/index.css';
You can use IconProvider
in @icon-park/vue-next
to set the default config globally:
<template>
<div>
<home/>
</div>
</template>
<script lang="ts">
import {DEFAULT_ICON_CONFIGS, IconProvider} from '@icon-park/vue-next';
import {Home} from '@icon-park/vue-next';
export default {
name: 'App',
setup(){
IconProvider({...DEFAULT_ICON_CONFIGS, prefix: 'icon'});
},
components: {
Home
}
};
</script>
You can use babel-plugin-import to import icons on demand.
Set config like this:
{
"plugins": [
[
"import",
{
"libraryName": "@icon-park/vue-next",
"libraryDirectory": "es/icons",
"camel2DashComponentName": false
}
]
]
}
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.
Usage:
<template>
<icon-park type="home" theme="filled"/>
</template>
<script>
import {IconPark} from '@icon-park/vue-next/es/all';
export default {
components: {
IconPark
}
}
</script>
| prop | description | type | default | note | | āāā- | ā | ā | ā | ā | | theme | Theme of the icons. | āoutlineā | āfilledā | ātwo-toneā | āmulti-colorā | āoutlineā | | size | The width/height of the icon | number | string | ā1emā | | spin | Rotate icon with animation | boolean | false | | fill | Colors of theme | string | string[] | ācurrentColorā | | strokeLinecap | the stroke-linecap prop of svg element | ābuttā | āroundā | āsquareā | āroundā | | strokeLinejoin | the stroke-linejoin prop of svg element | āmiterā | āroundā | ābevelā | āroundā | | strokeWidth | the stroke-width prop of svg element | number | 4 |