To use icons, you must import the IconDirective into your component's imports array. You then need to register the specific icons you want to use via IconService (static loading) or via provideAntIcons in your application configuration.
import { IconDirective, IconService } from '@ant-design/icons-angular';
import { AccountBookFill } from '@ant-design/icons-angular/icons';
import { Component, inject } from '@angular/core';
@Component({
selector: 'app-root',
standalone: true,
imports: [ IconDirective ],
template: `<span antIcon type="ant-cloud" theme="outline"></span>`
})
export class AppComponent {
readonly iconService = inject(IconService);
constructor() {
// Register specific icons to avoid massive bundle sizes
this.iconService.addIcon(...[ AccountBookFill ]);
// Optional: Configure two-tone color
this.iconService.twoToneColor = { primaryColor: '#1890ff' };
}
}