Skip to content

Commit ee11d54

Browse files
committed
docs(icon): add component icon examples to docs
1 parent 67e36ea commit ee11d54

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<script setup lang="ts">
2+
import { h, resolveComponent } from 'vue'
3+
4+
const UIcon = resolveComponent('UIcon')
5+
6+
const IconLightbulb = () => h(
7+
'svg',
8+
{ xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 24 24' },
9+
[
10+
h(
11+
'path',
12+
{
13+
'fill': 'none',
14+
'stroke': 'currentColor',
15+
'stroke-linecap': 'round',
16+
'stroke-linejoin': 'round',
17+
'stroke-width': 2,
18+
'd': 'M15 14c.2-1 .7-1.7 1.5-2.5c1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5c.7.7 1.3 1.5 1.5 2.5m0 4h6m-5 4h4'
19+
}
20+
)
21+
]
22+
)
23+
</script>
24+
25+
<template>
26+
<UIcon :name="IconLightbulb" class="size-5" />
27+
</template>

docs/content/docs/2.components/icon.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: A component to display any icon from Iconify.
2+
description: A component to display any icon from Iconify or another component.
33
category: element
44
links:
55
- label: Icônes
@@ -27,6 +27,30 @@ It's highly recommended to install the icons collections you need, read more abo
2727
:::
2828
::
2929

30+
## Examples
31+
32+
### SVG
33+
34+
You can also pass a Vue component into the `name` prop:
35+
36+
::component-example
37+
---
38+
name: 'icon-svg-example'
39+
---
40+
::
41+
42+
You can define your icon components yourself, or use [`unplugin-icons`](https://github.com/unplugin/unplugin-icons) to import them directly from SVG files:
43+
44+
```vue
45+
<script setup lang="ts">
46+
import IconLightbulb from '~icons/lucide/lightbulb'
47+
</script>
48+
49+
<template>
50+
<UIcon :name="IconLightbulb" class="size-5" />
51+
</template>
52+
```
53+
3054
## API
3155

3256
### Props

0 commit comments

Comments
 (0)