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

Vue

SolarProvider, useSolar, CSS variables, duotone, and stroke width for Vue 3.0+.

npm install @solar-icons/vue

Import patterns

// Per-style (no style suffix in name - style is in the path)
import { HeartIcon } from '@solar-icons/vue/bold'

// Single icon (lighter on the dev server — avoids resolving ~8k modules)
import { HeartIcon } from '@solar-icons/vue/bold/heart'

// Top-level (style suffix in name)
import { HeartBoldIcon } from '@solar-icons/vue'

// Dynamic (runtime style switching)
import { HeartIcon } from '@solar-icons/vue/dynamic'

Basic usage

<script setup>
import { HeartIcon } from '@solar-icons/vue/bold'
</script>

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

Duotone

<template>
    <HeartIcon color="#3b82f6" secondary-color="#f59e0b" :secondary-opacity="0.4" :size="48" />
</template>

<script setup>
import { HeartIcon } from '@solar-icons/vue/bold-duotone'
</script>

Stroke width

<template>
    <SettingsIcon :stroke-width="2" :size="24" />
</template>

<script setup>
import { SettingsIcon } from '@solar-icons/vue/linear'
</script>

SolarProvider

<script setup>
import { SolarProvider } from '@solar-icons/vue'
import { HeartIcon } from '@solar-icons/vue/bold'
</script>

<template>
    <SolarProvider color="#3b82f6" :size="24" :stroke-width="1.5">
        <HeartIcon />
    </SolarProvider>
</template>
PropCSS VariableFallback
color--solar-colorcurrentColor
size--solar-size24px
stroke-width--solar-stroke-width1.5
secondary-color--solar-secondary-colorcurrentColor
secondary-opacity--solar-secondary-opacity0.5

The provider does not set defaults. Icons fall back to these values through CSS when no provider or prop is specified.

useSolar

Returns reactive Refs. Must be called inside a <SolarProvider>.

<script setup>
import { useSolar } from '@solar-icons/vue'

const solar = useSolar()
</script>

<template>
    <button @click="solar.setColor('#ef4444')">Current: {{ solar.color }}</button>
</template>

Keep solar as a single object. Vue auto-unwraps the Refs when you read them through solar.color in the template. Destructuring (const { color } = useSolar()) loses reactivity in the template.

Vue Plugin

Configure defaults globally via the Vue plugin. No <SolarProvider> needed.

import { createApp } from 'vue'
import { SolarIconsPlugin } from '@solar-icons/vue/lib'
import App from './App.vue'

const app = createApp(App)
app.use(SolarIconsPlugin, {
    color: 'currentColor',
    size: 24,
    strokeWidth: 1.5,
    secondaryColor: '#3b82f6',
    secondaryOpacity: 0.5,
})
app.mount('#app')

Dynamic icons

<script setup>
import { HeartIcon } from '@solar-icons/vue/dynamic'
</script>

<template>
    <HeartIcon weight="BoldDuotone" color="#3b82f6" :size="32" />
</template>

Icon props

PropTypeDescription
colorstringIcon color
sizestring | numberWidth and height
strokeWidthstring | numberStroke width
secondaryColorstringDuotone accent color
secondaryOpacitynumberDuotone accent opacity
isolatedbooleanIgnores provider
altstringAccessibility label

In Vue templates, kebab-case attribute names map to camelCase props (e.g. :stroke-width="2" targets strokeWidth). Either form works in templates. Use kebab-case in <template>, camelCase in <script setup>.

CSS variables

Same five variables as React.

CSS classes

Every icon renders with class solar plus solar-{name}-{style} (e.g., solar-heart-bold). See the React page for examples.

ESM only

@solar-icons/vue is ESM-only. require() does not work.

How is this guide?

Last updated on

On this page