Skip to Content
IntegrationsVueHugeiconsIcon Wrapper

HugeiconsIcon Wrapper

The @hugeicons/vue package provides a universal HugeiconsIcon component that can render any icon from our libraries.
Think of it as a smart wrapper for Vue: you pass it an icon object, and it handles sizing, color, stroke width, and even switching between two icons for different states.

Props

PropTypeDefaultDescription
iconIconSvgObjectRequiredThe main icon component imported from an icon package
altIconIconSvgObject-Alternative icon component for states, interactions, or animations
showAltbooleanfalseWhen true, displays the altIcon instead of the main icon
sizenumber24Icon size in pixels
colorstringcurrentColorIcon color (CSS color value)
strokeWidthnumber1.5Width of the icon strokes (works with stroke-style icons)
absoluteStrokeWidthbooleanfalseWhen true, keeps the visual stroke width fixed as size changes
classstring-Additional CSS classes

State-based icons with altIcon and showAlt

Use altIcon and showAlt to swap between two icons based on component state:

<script setup> import { ref } from 'vue' import { HugeiconsIcon } from '@hugeicons/vue' import { SunIcon, Moon02Icon } from '@hugeicons/core-free-icons' const isDark = ref(false) </script> <template> <button @click="isDark = !isDark"> <HugeiconsIcon :icon="SunIcon" :altIcon="Moon02Icon" :showAlt="isDark" /> </button> </template>

Styling icons

You can style icons in a few ways:

  • size: controls the rendered icon size in pixels.
  • color: accepts any valid CSS color (e.g. #111827, rgb(0,0,0), currentColor).
  • strokeWidth: adjusts the thickness of stroke-based icons.
  • absoluteStrokeWidth: keeps that thickness fixed as the icon scales.
  • class: attach utility classes from Tailwind, CSS Modules, etc.
<script setup> import { HugeiconsIcon } from '@hugeicons/vue' import { Notification03Icon } from '@hugeicons/core-free-icons' </script> <template> <HugeiconsIcon :icon="Notification03Icon" :size="32" color="#6366f1" :strokeWidth="1.75" class="inline-block align-middle" /> </template>

When using currentColor, the icon inherits the text color from its parent, which works well inside buttons, links, and headings.

absoluteStrokeWidth changes how strokeWidth scales. By default the stroke grows with size, so a 48px icon has a stroke twice as thick as a 24px one. With absoluteStrokeWidth the stroke stays at the width you pass no matter the size, which keeps a set of differently sized icons visually consistent. It only takes effect when strokeWidth is set explicitly.

More patterns and examples