Solar Icons
Migration to v2

Angular Migration

Upgrade @solar-icons/angular to v2.

Try the codemod first

The V2 codemod can rename deterministic Angular imports and selectors in inline or resolvable external templates. It reports templates and API changes it cannot safely infer, which you should complete with this guide.

Standalone components

v2 components are standalone. They were already standalone before v2. No module removal needed.

Component names

v2 uses Solar-prefixed PascalCase imports with style suffixes. Before v2, icons used style-suffixed names without prefix.

Before (pre-v2):

import { HeartBold } from '@solar-icons/angular'

After (v2):

import { SolarHeartBold } from '@solar-icons/angular'

SolarProvider

v2 adds <solar-provider> for sharing styling via CSS custom properties:

import { SolarProvider, SolarHomeBold } from '@solar-icons/angular'

@Component({
    standalone: true,
    imports: [SolarProvider, SolarHomeBold],
    template: `
        <solar-provider color="#3b82f6" [size]="24" [strokeWidth]="1.5">
            <svg solarHomeBold></svg>
        </solar-provider>
    `,
})
export class AppComponent {}

useSolar

Child-driven API for components inside <solar-provider>:

import { useSolar } from '@solar-icons/angular'

function MyComponent() {
    const solar = useSolar()
    solar.setColor('#ef4444')
}

Set defaults with <solar-provider> props. In child components, read from useSolar() and write to it only in response to user events. Initial writes in a child constructor are overridden by the provider's inputs. Avoid them.

Duotone and stroke width

v2 adds duotone support and stroke width control for linear styles:

<svg solarHeartBoldDuotone secondaryColor="#f59e0b" [secondaryOpacity]="0.4" />
<svg solarSettingsLinear [strokeWidth]="2" />

Additional inputs

v2 icons accept additional inputs:

InputTypeDescription
strokeWidthstring | numberStroke width (linear styles only)
secondaryColorstringDuotone accent color
secondaryOpacitynumberDuotone accent opacity
isolatedbooleanIgnores provider CSS variables
altstringAccessibility label
ariaLabelstringaria-label attribute
titleAttrstringExplicit <title> text

Before v2, only size, color, alt, and mirrored were available.

Dynamic rendering (pre-v2)

The old SolarDynamicIcon directive + provideSolarIcons registry is still available, renamed to SolarIcon. Works identically. Register icons by name, then render by string or class reference.

import { SolarIcon, provideSolarIcons } from '@solar-icons/angular'
import { SolarHeartBold } from '@solar-icons/angular'

@Component({
    standalone: true,
    imports: [SolarIcon],
    template: '<ng-container solarIcon="SolarHeartBold" [size]="24" />',
    providers: [provideSolarIcons({ SolarHeartBold })],
})
export class AppComponent {}

Multi-style dynamic components

v2 adds multi-style components that bundle all 6 styles in one component and switch via weight input.

Import from the new @solar-icons/angular/dynamic entry point:

import { SolarHome } from '@solar-icons/angular/dynamic'

Use them directly in the template:

<svg solarHome weight="Bold" [size]="24" color="#ef4444" />

These components are independent of SolarIcon. No directive, no registry, no provider needed.

Which to choose

NeedSolution
One style, one file, minimal bundleStatic component (SolarHomeBold)
Switch styles at runtime on a known iconMulti-style component (SolarHome from ./dynamic)
Icons from API / CMS / user configSolarIcon directive + provideSolarIcons

CSS classes

v2 adds a base CSS class solar plus a per-icon variant solar-{kebab}-{style} on every icon:

<svg solarHomeBold></svg>
<!-- renders with: class="solar solar-home-bold" -->

Before v2, icons had no CSS classes.

How is this guide?

Last updated on

On this page