API Reference
Complete reference for all public APIs exported by the library.
SolarIconsComponent
The <solar-icon> component renders registered SVG icons. Uses ChangeDetectionStrategy.OnPush and ViewEncapsulation.None.
| Input | Type | Description |
|---|---|---|
| name | IconSet | The icon name to render (e.g. "heart", "star"). |
| iconStyle | StyleSet | The style variant of the icon. |
| size | string | number | Sets both width and height simultaneously. |
| width | string | number | Overrides the SVG width. |
| height | string | number | Overrides the SVG height. |
html
<solar-icon name="heart" iconStyle="bold" size="24" />
<solar-icon name="star" iconStyle="outline" width="32" height="32" />SolarIconsService
Root-provided service that manages the icon registry. Icons are stored in an internal lookup map indexed by name and style.
| Method | Signature | Description |
|---|---|---|
| addIcons | (...icons: IconDefinition[]) => void | Registers one or more icon definitions in the internal registry. |
typescript
import { inject } from '@angular/core';
import { SolarIconsService } from '@rchernando/solar-icons';
import { HeartBold, StarOutline } from '@rchernando/solar-icons/like';
const iconService = inject(SolarIconsService);
iconService.addIcons(HeartBold, StarOutline);Types
IconDefinition
The shape of each icon constant exported by the library.
typescript
interface IconDefinition {
name: string; // e.g. 'heart'
data: string; // raw SVG markup
style: string; // e.g. 'bold'
}IconSet
A union type of all valid icon names (1200+ values). Used as the type for the name input.
typescript
type IconSet = 'heart' | 'star' | 'user' | 'cart' | ... // 1200+ icon namesStyleSet
The six available icon style variants.
typescript
type StyleSet = 'bold' | 'bold-duotone' | 'linear' | 'outline' | 'broken' | 'line-duotone';provideSolarIcons()
A provider factory function that registers icons and returns an EnvironmentProviders token. Can be used at application level in appConfig or at route level for lazy-loaded features.
typescript
import { provideSolarIcons } from '@rchernando/solar-icons';
import { HeartBold, StarOutline } from '@rchernando/solar-icons/like';
// Signature
function provideSolarIcons(...icons: IconDefinition[]): EnvironmentProviders;
// Usage in app config
export const appConfig: ApplicationConfig = {
providers: [
provideSolarIcons(HeartBold, StarOutline)
]
};