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.

InputTypeDescription
nameIconSetThe icon name to render (e.g. "heart", "star").
iconStyleStyleSetThe style variant of the icon.
sizestring | numberSets both width and height simultaneously.
widthstring | numberOverrides the SVG width.
heightstring | numberOverrides 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.

MethodSignatureDescription
addIcons(...icons: IconDefinition[]) => voidRegisters 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 names

StyleSet

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)
  ]
};