아이콘
아이콘 (Icon)
Iconify에 있는 아이콘이나 다른 컴포넌트를 화면에 표시해 주는 컴포넌트예요. name prop에 아이콘 이름을 넣기만 하면 바로 사용할 수 있어요.
출처: Nuxt UI
본문
사용법 (Usage)
name prop을 사용해 아이콘을 표시해요.
<template>
<UIcon name="i-lucide-lightbulb" class="size-5" />
</template>
[!NOTE]
You can use any name from the https://iconify.design collection. Browse them easily on https://icones.js.org or search directly from your AI assistant using the
search-iconsMCP tool.
Nuxt:
[!CAUTION] See: /docs/getting-started/integrations/icons/nuxt#collections
It's highly recommended to install the icons collections you need, read more about this.
[!NOTE]
https://iconify.design 컬렉션에 있는 어떤 아이콘 이름이라도 사용할 수 있어요. https://icones.js.org에서 쉽게 탐색하거나, AI 어시스턴트에서
search-iconsMCP 도구로 바로 검색할 수 있어요.
[!CAUTION]
필요한 아이콘 컬렉션을 설치하는 것을 강력히 권장해요. 관련 내용은 /docs/getting-started/integrations/icons/nuxt#collections 문서를 참고해 주세요.
예시 (Examples)
SVG
name prop에 Vue 컴포넌트를 전달할 수도 있어요.
<script setup lang="ts">
import { h } from 'vue'
const IconLightbulb = () => h(
'svg',
{ xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 24 24' },
[
h(
'path',
{
'fill': 'none',
'stroke': 'currentColor',
'stroke-linecap': 'round',
'stroke-linejoin': 'round',
'stroke-width': 2,
'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'
}
)
]
)
</script>
<template>
<UIcon :name="IconLightbulb" class="size-5" />
</template>
아이콘 컴포넌트를 직접 정의하거나, unplugin-icons를 사용해 SVG 파일에서 바로 불러올 수도 있어요.
<script setup lang="ts">
import IconLightbulb from '~icons/lucide/lightbulb'
</script>
<template>
<UIcon :name="IconLightbulb" class="size-5" />
</template>
API
Props
/**
* Props for the Icon component
*/
interface IconProps {
name: any;
mode?: "svg" | "css" | undefined;
size?: string | number | undefined;
customize?: boolean | IconifyIconCustomizeCallback | null | undefined;
}
변경 내역 (Changelog)
사이트맵 (Sitemap)
전체 사이트맵에서 모든 페이지를 확인할 수 있어요.