Fundamentos

VIcon

Componente3 exemplos2 propsA2UI · Icon

Renderiza um ícone SVG a partir de um objeto **Iconify** (`IconifyIcon`). O ícone herda `currentColor`, então acompanha a cor do texto e o tema.

Importação
<script setup lang="ts">
import { VIcon } from 'vueui-nova-kit'
</script>

Uso

Exemplo
<script setup lang="ts">
import homeIcon from '@iconify-icons/keyline-icons/home'
import { VIcon } from 'vueui-nova-kit'
</script>

<template>
  <VIcon :icon="homeIcon" size="md" />
</template>

Playground

Os controles abaixo são gerados a partir das props declaradas em VIcon.types.ts; o código acompanha cada mudança.

Exemplos

Variantes, tamanhos e estados, extraídos das stories da biblioteca.

Default

Variação Padrão. Estado padrão do componente; use a aba Controls para experimentar as props ao vivo.

Ver código
vue
<script setup lang="ts">
import { VIcon } from 'vueui-nova-kit'

const icon = {
  width: 24,
  height: 24,
  body: '<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.2928 9.4009L13.2928 3.4703C12.5468 2.8383 11.4532 2.8383 10.7072 3.4703L3.7072 9.4009C3.2586 9.7809 3 10.339 3 10.9268L3 19C3 20.1046 3.8954 21 5 21L19 21C20.1046 21 21 20.1046 21 19L21 10.9268C21 10.339 20.7414 9.7809 20.2928 9.4009ZM9 21V14H15V21"/>',
}
</script>

<template>
  <VIcon :icon="icon" />
</template>

Sizes

Variação Tamanhos.

Ver código
vue
<script setup lang="ts">
import { VIcon } from 'vueui-nova-kit'

const homeIcon = {
  width: 24,
  height: 24,
  body: '<path fill=\'none\' stroke=\'currentColor\' stroke-linecap=\'round\' stroke-linejoin=\'round\' stroke-width=\'2\' d=\'M20.2928 9.4009L13.2928 3.4703C12.5468 2.8383 11.4532 2.8383 10.7072 3.4703L3.7072 9.4009C3.2586 9.7809 3 10.339 3 10.9268L3 19C3 20.1046 3.8954 21 5 21L19 21C20.1046 21 21 20.1046 21 19L21 10.9268C21 10.339 20.7414 9.7809 20.2928 9.4009ZM9 21V14H15V21\'/>'
}
</script>

<template>
  <div style="display:flex;gap:16px;align-items:center;">
        <VIcon :icon="homeIcon" size="sm" /><VIcon :icon="homeIcon" size="md" /><VIcon :icon="homeIcon" size="lg" />
      </div>
</template>

Inherits Color

Variação Inherits Color.

Ver código
vue
<script setup lang="ts">
import { VIcon } from 'vueui-nova-kit'

const searchIcon = {
  width: 24,
  height: 24,
  body: '<path fill=\'none\' stroke=\'currentColor\' stroke-linecap=\'round\' stroke-linejoin=\'round\' stroke-width=\'2\' d=\'M17 10C17 13.866 13.866 17 10 17C6.13401 17 3 13.866 3 10C3 6.13401 6.13401 3 10 3C13.866 3 17 6.13401 17 10ZM15 15L21 21\'/>'
}
const settingsIcon = {
  width: 24,
  height: 24,
  body: '<path fill=\'none\' stroke=\'currentColor\' stroke-linecap=\'round\' stroke-linejoin=\'round\' stroke-width=\'2\' d=\'M9.8826 3.31L9.6447 5.26C9.5876 5.73 9.3203 6.14 8.9222 6.37L8.7712 6.46C8.3732 6.7 7.8905 6.73 7.467 6.55L5.6993 5.78C5.0174 5.49 4.228 5.76 3.8579 6.41L3.1967 7.59C2.8267 8.24 2.9918 9.07 3.5819 9.53L5.1117 10.71C5.4781 11 5.6935 11.44 5.6935 11.91V12.09C5.6935 12.56 5.4781 13 5.1117 13.29L3.5819 14.47C2.9918 14.93 2.8267 15.76 3.1967 16.41L3.8579 17.59C4.228 18.24 5.0174 18.51 5.6993 18.22L7.467 17.45C7.8905 17.27 8.3732 17.3 8.7712 17.54L8.9222 17.63C9.3203 17.86 9.5876 18.27 9.6447 18.74L9.8826 20.69C9.9744 21.44 10.5987 22 11.3388 22H12.6612C13.4013 22 14.0256 21.44 14.1173 20.69L14.3554 18.74C14.4124 18.27 14.6798 17.86 15.0778 17.63L15.2287 17.54C15.6268 17.3 16.1095 17.27 16.5329 17.45L18.3007 18.22C18.9826 18.51 19.772 18.24 20.1421 17.59L20.8033 16.41C21.1733 15.76 21.0082 14.93 20.4181 14.47L18.8883 13.29C18.5219 13 18.3066 12.56 18.3066 12.09V11.91C18.3066 11.44 18.5219 11 18.8883 10.71L20.4181 9.53C21.0082 9.07 21.1733 8.24 20.8033 7.59L20.1421 6.41C19.772 5.76 18.9826 5.49 18.3007 5.78L16.5329 6.55C16.1095 6.73 15.6268 6.7 15.2287 6.46L15.0778 6.37C14.6798 6.14 14.4124 5.73 14.3554 5.26L14.1173 3.31C14.0256 2.56 13.4013 2 12.6612 2H11.3388C10.5987 2 9.9744 2.56 9.8826 3.31ZM12 9.5C13.3807 9.5 14.5 10.6193 14.5 12C14.5 13.3807 13.3807 14.5 12 14.5C10.6193 14.5 9.5 13.3807 9.5 12C9.5 10.6193 10.6193 9.5 12 9.5Z\'/>'
}
const sparklesIcon = {
  width: 24,
  height: 24,
  body: '<path fill=\'none\' stroke=\'currentColor\' stroke-linecap=\'round\' stroke-linejoin=\'round\' stroke-width=\'2\' d=\'M15.4651 9.1794L16.7409 12.4141C16.8933 12.8006 17.1994 13.1067 17.5859 13.2591L20.8206 14.5349C21.0117 14.6102 21.1372 14.7947 21.1372 15C21.1372 15.2053 21.0117 15.3898 20.8206 15.4651L17.5859 16.7409C17.1994 16.8933 16.8933 17.1994 16.7409 17.5859L15.4651 20.8206C15.3898 21.0117 15.2053 21.1372 15 21.1372C14.7947 21.1372 14.6102 21.0117 14.5349 20.8206L13.2591 17.5859C13.1067 17.1994 12.8006 16.8933 12.4141 16.7409L9.1794 15.4651C8.9883 15.3898 8.8628 15.2053 8.8628 15C8.8628 14.7947 8.9883 14.6102 9.1794 14.5349L12.4141 13.2591C12.8006 13.1067 13.1067 12.8006 13.2591 12.4141L14.5349 9.1794C14.6102 8.9883 14.7947 8.8628 15 8.8628C15.2053 8.8628 15.3898 8.9883 15.4651 9.1794ZM6.7151 3.1794L7.2131 4.4419C7.3655 4.8285 7.6715 5.1345 8.0581 5.2869L9.3206 5.7849C9.5117 5.8602 9.6372 6.0447 9.6372 6.25C9.6372 6.4553 9.5117 6.6398 9.3206 6.7151L8.0581 7.2131C7.6715 7.3655 7.3655 7.6715 7.2131 8.0581L6.7151 9.3206C6.6398 9.5117 6.4553 9.6372 6.25 9.6372C6.0447 9.6372 5.8602 9.5117 5.7849 9.3206L5.2869 8.0581C5.1345 7.6715 4.8285 7.3655 4.4419 7.2131L3.1794 6.7151C2.9883 6.6398 2.8628 6.4553 2.8628 6.25C2.8628 6.0447 2.9883 5.8602 3.1794 5.7849L4.4419 5.2869C4.8285 5.1345 5.1345 4.8285 5.2869 4.4419L5.7849 3.1794C5.8602 2.9883 6.0447 2.8628 6.25 2.8628C6.4553 2.8628 6.6398 2.9883 6.7151 3.1794Z\'/>'
}
</script>

<template>
  <div style="display:flex;gap:16px;align-items:center;">
        <span style="color:var(--v-color-primary)"><VIcon :icon="searchIcon" size="lg" /></span>
        <span style="color:var(--v-color-success-base, green)"><VIcon :icon="settingsIcon" size="lg" /></span>
        <span style="color:var(--v-color-text-muted)"><VIcon :icon="sparklesIcon" size="lg" /></span>
      </div>
</template>

Props

PropTipoDefaultDescrição
iconIconifyIcon——
sizeVIconSize"md"—

Events

Não emite eventos.

Slots

Sem slots.

Fonte: src/components/primitives/VIcon/VIcon.vue · tipos: src/components/primitives/VIcon/VIcon.types.ts