Nuxt
Solar Icons Nuxt module. Auto-import of all icon components with a configurable name prefix.
npm install @solar-icons/nuxtInstallation
The module wraps @solar-icons/vue and provides:
- Auto-imported icons: all 7,608 static icons + 1,268 dynamic icons
SolarProvideranduseSolar: auto-imported#solar-iconsaliases: for explicit imports with full TypeScript support- Provider defaults: configure default color, size, stroke width from
nuxt.config.ts
Module options
| Option | Type | Default | Description |
|---|---|---|---|
namePrefix | string | 'Solar' | Prefix for auto-imported component names |
autoImport | boolean | true | Register all icons as auto-imported components |
provider | boolean | true | Inject global provider state wrapping the app |
color | string | 'currentColor' | Default icon color (requires provider: true) |
size | string | number | 24 | Default icon size (requires provider: true) |
strokeWidth | number | 1.5 | Default stroke width (requires provider: true) |
secondaryColor | string | 'currentColor' | Default duotone accent color (requires provider: true) |
secondaryOpacity | number | 0.5 | Default duotone accent opacity (requires provider: true) |
// 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>. Options you do not set fall back to the module defaults above.
When provider: false, the styling options are ignored and the module warns about it. Set up the state manually: either call createSolarIcons from a Nuxt plugin, or wrap app.vue in <SolarProvider>:
<!-- app.vue -->
<template>
<SolarProvider color="#ef4444" :size="24">
<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.
| Alias | Resolves to | Content |
|---|---|---|
#solar-icons | @solar-icons/vue | Main barrel (7,608 icons) |
#solar-icons/lib | @solar-icons/vue/lib | SolarProvider, useSolar |
#solar-icons/dynamic | @solar-icons/vue/dynamic | Dynamic icons (1,268) |
#solar-icons/bold | @solar-icons/vue/bold | Bold style barrel |
#solar-icons/bold-duotone | @solar-icons/vue/bold-duotone | BoldDuotone style barrel |
#solar-icons/broken | @solar-icons/vue/broken | Broken style barrel |
#solar-icons/linear | @solar-icons/vue/linear | Linear style barrel |
#solar-icons/line-duotone | @solar-icons/vue/line-duotone | LineDuotone style barrel |
#solar-icons/outline | @solar-icons/vue/outline | Outline 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 path | Re-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.
With provider: true (default), useSolar() works anywhere in the app: the module provides a global context through the runtime plugin, and the defaults live on document.body as CSS variables.
With provider: false, useSolar() must be called inside a <SolarProvider> tree that you place yourself. The provider uses scoped provide/inject; there is no global context.
ESM only
@solar-icons/nuxt is ESM-only.
How is this guide?
Last updated on
React Native
React Context-based SolarProvider, duotone, and stroke width for React Native 0.72+. Requires react-native-svg.
Static
Static assets and utilities for Solar Icons that work without JavaScript frameworks. This package provides individual SVG files, an SVG sprite, and Node.js utilities for server-side string templating.