2021-10-01 09:19:36 +02:00
# Lucide Vue
Implementation of the lucide icon library for Vue applications.
2022-02-01 19:26:07 +01:00
> ⚠️ This version of lucide is for Vue 2, For Vue 3 got to [lucide-vue-next](lucide-vue-next)
2021-10-01 09:19:36 +02:00
## Installation
```sh
yarn add lucide-vue
2022-10-27 08:19:45 +02:00
```
2021-10-01 09:19:36 +02:00
2022-10-27 08:19:45 +02:00
or
2021-10-01 09:19:36 +02:00
2022-10-27 08:19:45 +02:00
```sh
2021-10-01 09:19:36 +02:00
npm install lucide-vue
```
## How to use
2022-10-03 16:36:33 +02:00
It's build with ESmodules so it's completely tree-shakable.
2021-10-01 09:19:36 +02:00
Each icon can be imported as a vue component.
### Example
You can pass additional props to adjust the icon.
2022-10-27 08:19:45 +02:00
```html
2021-10-01 09:19:36 +02:00
<template>
2022-10-27 08:19:45 +02:00
<Camera color="red" :size="32" />
2021-10-01 09:19:36 +02:00
</template>
<script>
2022-10-27 08:19:45 +02:00
// Returns Vue component
import { Camera } from 'lucide-vue';
2021-10-01 09:19:36 +02:00
2022-10-27 08:19:45 +02:00
export default {
name: 'My Component',
components: { Camera }
};
2021-10-01 09:19:36 +02:00
</script>
```
### Props
2022-10-27 08:19:45 +02:00
| name | type | default |
| -------------- | -------- | ------------ |
| `size` | _ Number _ | 24 |
| `color` | _ String _ | currentColor |
| `strokeWidth` | _ Number _ | 2 |
| `defaultClass` | _ String _ | lucide-icon |
2021-10-01 09:19:36 +02:00
### Custom props
You can also pass custom props that will be added in the svg as attributes.
2022-10-27 08:19:45 +02:00
```html
2021-10-01 09:19:36 +02:00
<template>
<Camera fill="red" />
</template>
```
### One generic icon component
It is possible to create one generic icon component to load icons.
2022-02-01 19:26:07 +01:00
> ⚠️ Example below importing all EsModules, caution using this example, not recommended when you using bundlers, your application build size will grow strongly.
2021-10-01 09:19:36 +02:00
#### Icon Component Example
2022-10-27 08:19:45 +02:00
```html
2021-10-01 09:19:36 +02:00
<template>
<component :is="icon" />
</template>
<script>
2022-10-27 08:19:45 +02:00
import * as icons from 'lucide-vue';
export default {
props: {
name: {
type: String,
required: true
}
2021-10-01 09:19:36 +02:00
},
2022-10-27 08:19:45 +02:00
computed: {
icon() {
return icons[this.name];
}
}
};
2021-10-01 09:19:36 +02:00
</script>
```
##### Then you can use it like this
2022-10-27 08:19:45 +02:00
```html
2021-10-01 09:19:36 +02:00
<template>
<div id="app">
<Icon name="Airplay" />
</div>
</template>
```