2021-10-01 09:19:36 +02:00
# Lucide Vue Next
Implementation of the lucide icon library for Vue 3 applications.
2022-09-12 22:26:35 +03:00
> ⚠️ This version of lucide is for Vue 3, For Vue 2 got to [lucide-vue](lucide-vue)
2021-10-01 09:19:36 +02:00
## Installation
2022-02-01 19:26:07 +01:00
**With yarn**
```bash
2021-10-01 09:19:36 +02:00
yarn add lucide-vue-next
2022-02-01 19:26:07 +01:00
```
2021-10-01 09:19:36 +02:00
2022-02-01 19:26:07 +01:00
**With npm**
2021-10-01 09:19:36 +02:00
2022-02-01 19:26:07 +01:00
```bash
2021-10-01 09:19:36 +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-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-02-01 19:26:07 +01:00
``` html
2021-10-01 09:19:36 +02:00
<template>
<Camera
color="red"
:size="32"
/>
</template>
2022-10-23 18:30:39 +02:00
<script setup>
2021-10-01 09:19:36 +02:00
import { Camera } from 'lucide-vue-next';
</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-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-02-01 19:26:07 +01: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-02-01 19:26:07 +01:00
``` html
2021-10-01 09:19:36 +02:00
<template>
2023-04-20 16:08:34 +02:00
<component
:is="icon"
:size="size"
:color="color"
:stroke-width="strokeWidth" :default-class="defaultClass"
/>
2021-10-01 09:19:36 +02:00
</template>
2022-10-23 18:30:39 +02:00
<script setup>
import { computed } from 'vue';
2021-10-01 09:19:36 +02:00
import * as icons from "lucide-vue-next";
2022-10-23 18:30:39 +02:00
const props = defineProps({
name: {
type: String,
required: true
2021-10-01 09:19:36 +02:00
},
2022-10-23 18:30:39 +02:00
size: Number,
color: String,
strokeWidth: Number,
defaultClass: String
})
2022-02-01 19:26:07 +01:00
2022-10-23 18:30:39 +02:00
const icon = computed(() => icons[props.name]);
2021-10-01 09:19:36 +02:00
</script>
```
##### Then you can use it like this
2022-02-01 19:26:07 +01:00
``` html
2021-10-01 09:19:36 +02:00
<template>
<div id="app">
<Icon name="Airplay" />
</div>
</template>
```
2022-10-23 18:30:39 +02:00
All other props listed above also work on the `Icon` Component.