2021-05-20 21:24:54 +02:00
# Lucide Vue Next
Implementation of the lucide icon library for Vue 3 applications.
> What is lucide? Read it [here](https://github.com/lucide-icons/lucide#what-is-lucide).
2022-10-19 12:46:38 +02:00
> :warning: This version of lucide is for Vue 3, For Vue 2 got to [lucide-vue](https://github.com/lucide-icons/lucide/tree/main/packages/lucide-vue#lucide-vue)
2021-05-20 21:24:54 +02:00
## Installation
```sh
yarn add lucide-vue-next
2022-10-27 08:19:45 +02:00
```
2021-05-20 21:24:54 +02:00
2022-10-27 08:19:45 +02:00
or
2021-05-20 21:24:54 +02:00
2022-10-27 08:19:45 +02:00
```sh
2021-05-20 21:24:54 +02:00
npm install lucide-vue-next
```
## How to use
2022-10-03 16:36:33 +02:00
It's build with ESmodules so it's completely tree-shakable.
2021-05-20 21:24:54 +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
```vue
2021-05-20 21:24:54 +02:00
<template>
2022-10-27 08:19:45 +02:00
<Camera color="red" :size="32" />
2021-05-20 21:24:54 +02:00
</template>
<script>
// Returns Vue component
import { Camera } from 'lucide-vue-next';
export default {
2022-10-27 08:19:45 +02:00
name: 'My Component',
2021-05-20 21:24:54 +02:00
components: { Camera }
2022-10-27 08:19:45 +02:00
};
2021-05-20 21:24:54 +02:00
</script>
```
### Props
2023-04-20 16:08:34 +02:00
| name | type | default |
| ----------------------- | --------- | ------------ |
| `size` | * number * | 24 |
| `color` | * string * | currentColor |
| `stroke-width` | * number * | 2 |
| `absolute-stroke-width` | * boolean * | false |
| `default-class` | * string * | lucide-icon |
2021-05-20 21:24:54 +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
```vue
2021-05-20 21:24:54 +02:00
<template>
<Camera fill="red" />
</template>
```
### One generic icon component
It is possible to create one generic icon component to load icons.
> :warning: Example below importing all EsModules, caution using this example, not recommended when you using bundlers, your application build size will grow strongly.
#### Icon Component Example
2022-10-27 08:19:45 +02:00
```vue
2021-05-20 21:24:54 +02:00
<template>
<component :is="icon" />
</template>
<script>
2022-10-27 08:19:45 +02:00
import * as icons from 'lucide-vue-next';
2021-05-20 21:24:54 +02:00
export default {
props: {
name: {
type: String,
2022-10-27 08:19:45 +02:00
required: true
}
2021-05-20 21:24:54 +02:00
},
computed: {
icon() {
return icons[this.name];
2022-10-27 08:19:45 +02:00
}
}
2021-05-20 21:24:54 +02:00
};
</script>
```
##### Then you can use it like this
2022-10-27 08:19:45 +02:00
```vue
2021-05-20 21:24:54 +02:00
<template>
<div id="app">
<Icon name="Airplay" />
</div>
</template>
```