Solar Icons v2 is in beta. APIs may change before the stable release. Report issues
Solar Icons
Frameworks

Nuxt

Solar Icons Nuxt module. Auto-import of all icon components with a configurable name prefix.

npm install @solar-icons/nuxt

Installation

The module wraps @solar-icons/vue and provides:

  • Auto-imported icons: all 7,476 static icons + 1,246 dynamic icons
  • SolarProvider and useSolar: auto-imported
  • #solar-icons aliases: for explicit imports with full TypeScript support
  • Provider defaults: configure default color, size, stroke width from nuxt.config.ts

Module options

OptionTypeDefaultDescription
namePrefixstring'Solar'Prefix for auto-imported component names
autoImportbooleantrueRegister all icons as auto-imported components
providerbooleantrueInject global provider state wrapping the app
colorstring'currentColor'Default icon color
sizestring | number24Default icon size
strokeWidthnumber1.5Default stroke width
secondaryColorstringDefault duotone accent color
secondaryOpacitynumberDefault duotone accent opacity (0–1)
// nuxt.config.ts
export default defineNuxtConfig({
    modules: ['@solar-icons/nuxt'],
    solarIcons: {
        namePrefix: 'Solar',
        autoImport: true,
        provider: true,
        color: 'currentColor',
        size: 24,
        strokeWidth: 1.5,
        secondaryColor: '#3b82f6',
        secondaryOpacity: 0.5,
    },
})

When provider: true (default), the module injects a global SolarState into the Nuxt Vue app and writes the configured defaults as --solar-* CSS variables on document.body (client side). useSolar() works in any component without a wrapping <SolarProvider>.

When provider: false, set up the state manually. Either call createSolarIcons from a Nuxt plugin, or wrap app.vue in <SolarProvider>:

<!-- app.vue -->
<template>
    <SolarProvider>
        <NuxtPage />
    </SolarProvider>
</template>

Auto-import

With autoImport: true (default), every icon is available in templates without explicit imports. The module registers two sets of components:

Main barrel (disambiguated names)

Pattern: {prefix}{IconName}{Style}Icon. Style is always explicit in the name.

<template>
    <SolarHeartBoldIcon color="#ef4444" :size="32" />
    <SolarSettingsOutlineIcon :stroke-width="2" />
    <SolarHomeBoldDuotoneIcon secondary-color="#3b82f6" :secondary-opacity="0.4" />
</template>

Dynamic icons (runtime style switching)

Pattern: {prefix}{IconName}Icon (no style suffix). These wrap all 6 styles and accept a weight prop.

<template>
    <SolarArrowUpIcon weight="Bold" />
    <SolarHeartIcon :weight="selectedWeight" />
</template>

SolarProvider and useSolar are auto-imported regardless of the autoImport setting.

Explicit imports with #solar-icons aliases

The module registers Nuxt aliases that resolve to @solar-icons/vue sub-paths. These work in both <script> and <template> and have full TypeScript support.

AliasResolves toContent
#solar-icons@solar-icons/vueMain barrel (7,476 icons)
#solar-icons/lib@solar-icons/vue/libSolarProvider, useSolar
#solar-icons/dynamic@solar-icons/vue/dynamicDynamic icons (1,246)
#solar-icons/bold@solar-icons/vue/boldBold style barrel
#solar-icons/bold-duotone@solar-icons/vue/bold-duotoneBoldDuotone style barrel
#solar-icons/broken@solar-icons/vue/brokenBroken style barrel
#solar-icons/linear@solar-icons/vue/linearLinear style barrel
#solar-icons/line-duotone@solar-icons/vue/line-duotoneLineDuotone style barrel
#solar-icons/outline@solar-icons/vue/outlineOutline style barrel
<script setup>
import { HeartIcon } from '#solar-icons/bold'
import { HeartIcon as DynamicHeart } from '#solar-icons/dynamic'
import { useSolar } from '#solar-icons/lib'
</script>

<template>
    <HeartIcon color="#ef4444" :size="32" />
    <DynamicHeart weight="Outline" />
</template>

Entry points

For consumers outside Nuxt (scripts, tests, other frameworks), the package also exports standard entry points:

Import pathRe-exports
@solar-icons/nuxt/icons@solar-icons/vue (main barrel)
@solar-icons/nuxt/icons/{style}@solar-icons/vue/{style}
@solar-icons/nuxt/dynamic@solar-icons/vue/dynamic
@solar-icons/nuxt/lib@solar-icons/vue/lib

In a Nuxt app, prefer the #solar-icons aliases. They resolve at build time and have TypeScript support via the generated tsconfig.

SolarProvider and useSolar

The provider and composable work identically to the Vue package. See the Vue documentation for props, CSS variables, and usage examples.

useSolar() must be called inside a <SolarProvider> tree. The provider uses scoped provide/inject. No global context.

ESM only

@solar-icons/nuxt is ESM-only.

How is this guide?

Last updated on

On this page