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

Angular

SolarProvider, useSolar, CSS variables, duotone, and stroke width for Angular 17+.

npm install @solar-icons/angular

Standalone components with signal-based inputs. Solar-prefixed PascalCase component names with attribute selectors on <svg>.

Import patterns

// Top-level (all icons + lib)
import { SolarHeartBold, SolarProvider, useSolar } from '@solar-icons/angular'

// Dynamic icons
import * as dynamicIcons from '@solar-icons/angular/dynamic'
import { SolarHome } from '@solar-icons/angular/dynamic'

Static components

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

@Component({
    standalone: true,
    imports: [SolarHeartBold],
    template: '<svg solarHeartBold color="#ef4444" [size]="32" />',
})
export class AppComponent {}

Duotone

<svg
    solarHeartBoldDuotone
    color="#3b82f6"
    secondaryColor="#f59e0b"
    [secondaryOpacity]="0.4"
    [size]="48" />

Stroke width

Linear, LineDuotone, and Broken styles support strokeWidth:

<svg solarSettingsLinear [strokeWidth]="2" [size]="24" />

SolarProvider

Wrap a subtree to share icon 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 {}
InputCSS VariableFallback
color--solar-colorcurrentColor
size--solar-size24px
strokeWidth--solar-stroke-width1.5
secondaryColor--solar-secondary-colorcurrentColor
secondaryOpacity--solar-secondary-opacity0.5

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

useSolar

Call useSolar() inside a component that is a descendant of <solar-provider> to access the provider state. The provider must be an ancestor in the template, not a child.

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

const solar = useSolar()
solar.setColor('#ef4444')
solar.setSize(32)
solar.setSecondaryColor('#f59e0b')
solar.setSecondaryOpacity(0.4)

The component using useSolar() must be projected into <solar-provider> (the provider wraps it):

<solar-provider>
    <app-controls />
</solar-provider>

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.

Dynamic icons

Two complementary features share this name but solve different problems.

Multi-style components

Import a component that bundles all 6 styles and switches via weight. Use it directly in your template. No directive needed.

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

@Component({
    standalone: true,
    imports: [SolarHome],
    template: '<svg solarHome weight="Bold" [size]="24" color="#ef4444" />',
})
export class AppComponent {}

Available from @solar-icons/angular/dynamic (barrel) or @solar-icons/angular/dynamic/home (single).

Dynamic rendering with SolarIcon

The SolarIcon directive creates icons at runtime from a component class or registered name. Use it when the icon to render is only known at runtime (data-driven, CMS, user config).

import { Component } from '@angular/core'
import { SolarIcon, provideSolarIcons } from '@solar-icons/angular'
import { SolarHome } from '@solar-icons/angular/dynamic'
import { SolarHeartBold } from '@solar-icons/angular'

@Component({
    standalone: true,
    imports: [SolarIcon],
    template: `
        <ng-container [solarIcon]="icon" [weight]="'Bold'" [size]="24" color="red" />
        <ng-container solarIcon="SolarHeartBold" [size]="24" />
    `,
    providers: [provideSolarIcons({ SolarHeartBold })],
})
export class AppComponent {
    icon = SolarHome
}
UsageImportRequires registry
[solarIcon]="SomeClass"Class referenceNo
solarIcon="'RegisterName'"String nameprovideSolarIcons

SolarIcon accepts size, color, strokeWidth, weight, secondaryColor, secondaryOpacity, and alt. All forward to the created icon.

Icon props

InputTypeDescription
colorstringIcon color
sizestring | numberWidth and height
strokeWidthstring | numberStroke width
secondaryColorstringDuotone accent color
secondaryOpacitynumberDuotone accent opacity
isolatedbooleanIgnores provider
altstringAccessibility label
ariaLabelstringaria-label attribute
titleAttrstringExplicit <title> text

Angular inputs are camelCase. Bind them in templates with [strokeWidth]="2", not [stroke-width].

CSS variables

Icons read from CSS custom properties when explicit inputs are omitted:

:host {
    --solar-color: #ef4444;
    --solar-size: 32px;
    --solar-stroke-width: 2;
}

CSS classes

Every icon renders with class solar plus solar-{kebab-name}-{style}. For example, SolarHeartBold renders with solar solar-heart-bold.

ESM only

@solar-icons/angular is ESM-only.

How is this guide?

Last updated on

On this page