import { Component } from '@angular/core';
import { WrIcon, lucideIcons, provideWrIcons } from 'ngwr/icon';
@Component({ imports: [WrIcon] })
export class MyComponent {}Icon
Renders an SVG icon you register by name; ngwr ships none of its own.
Installation
Import the class, and @use the entry point in your global styles: without it the component renders unstyled.
Register icons
lucideIcons() for Lucide, svgIcon() for any set that ships SVG files.
pnpm add lucideimport { Plus, Trash } from 'lucide';
import { lucideIcons, provideWrIcons } from 'ngwr/icon';
bootstrapApplication(AppComponent, {
providers: [provideWrIcons(lucideIcons({ plus: Plus, trash: Trash }))],
});Use
The icon is hidden from screen readers, so an icon-only button needs its own aria-label.
import { WrIcon } from 'ngwr/icon';
@Component({ imports: [WrIcon], templateUrl: './my.html' })
export class MyComponent {}
<wr-icon name="plus" />
<wr-icon name="trash" />Custom inline SVG
Wrap a one-off SVG in svgIcon() and style it with fill and stroke: style, <style>, <image>, <a>, <foreignObject>, filters and SMIL are removed.
import { svgIcon, provideWrIcons } from 'ngwr/icon';
provideWrIcons([
svgIcon('brand', '<svg viewBox="0 0 24 24"><path d="…"/></svg>'),
]);API
| Name | Description | Type | Default |
|---|---|---|---|
namerequired | Name the icon was registered under in provideWrIcons(). An unregistered name renders nothing and logs in dev mode — ngwr ships no icons itself. | WrIconName | — |
CSS variables
Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/icon's own element.
| Variable | Default | Declared on |
|---|---|---|
--wr-icon-size | 1.2em | :root |
Dependencies
| Used by | Alert, Badge, Breadcrumbs, Button, Checkbox, Command Palette, Context Menu, Dropdown, Empty, Radio, Segmented, Sidebar, Speed Dial |
|---|