docs/guide/packages/angular.md
@lucide/angular::: warning
This documentation is for @lucide/angular.
To learn about our legacy package for Angular, please refer to lucide-angular.
:::
A standalone, signal-based, zoneless implementation of Lucide icons for Angular.
What you can accomplish:
This package requires Angular 17+ and uses standalone components, signals, and zoneless change detection.
::: code-group
pnpm add @lucide/angular
yarn add @lucide/angular
npm install @lucide/angular
bun add @lucide/angular
:::
Every icon can be imported as a ready-to-use standalone component:
<svg lucideFileText></svg>
import { Component } from '@angular/core';
import { LucideFileText } from '@lucide/angular';
@Component({
selector: 'app-foobar',
templateUrl: './foobar.html',
imports: [LucideFileText],
})
export class Foobar { }
::: tip
Standalone icon components use the selector svg[lucide{PascalCaseIconName}].
This ensures minimal bloating of the DOM and the ability to directly manipulate all attributes of the resulting SVG element. :::
You may also use the dynamic LucideIcon component to dynamically render icons.
You may pass imported icons directly to the component:
@for (item of items) {
<a navbarItem [routerLink]="item.routerLink">
<svg [lucideIcon]="item.icon"></svg>
{{ item.title }}
</a>
}
import { Component } from '@angular/core';
import { LucideIcon, LucideHouse, LucideUsersRound } from '@lucide/angular';
import { NavbarItem, NavbarItemModel } from './navbar-item';
@Component({
selector: 'app-navbar',
templateUrl: './navbar.html',
imports: [LucideIcon, NavbarItem],
})
export class Navbar {
readonly items: NavbarItemModel[] = [
{
title: 'Home',
icon: LucideHouse,
routerLink: [''],
},
{
title: 'Users',
icon: LucideUsersRound,
routerLink: ['admin/users'],
},
];
}
Alternatively, the component also accepts string inputs.
To use icons this way, first, you have to provide icons via provideLucideIcons:
:::code-group
import { ApplicationConfig } from '@angular/core';
import { provideLucideIcons, LucideCircleCheck, LucideCircleX } from '@lucide/angular';
export const appConfig: ApplicationConfig = {
providers: [
// ...
provideLucideIcons(
LucideCircleCheck,
LucideCircleX,
),
]
};
<svg lucideIcon="circle-check"></svg>
import { Component } from '@angular/core';
import { LucideIcon } from '@lucide/angular';
@Component({
selector: 'app-foobar',
templateUrl: './template-url',
imports: [LucideIcon],
})
export class Foobar { }
:::
::: tip For optimal bundle size, provide icons at the highest appropriate level in your application.
Providing all icons at the root level may increase your initial bundle size, while providing them at feature module level enables better code splitting. :::
::: warning
While you may provide your icons at any level of the dependency injection tree, be aware that Angular's DI system is hierarchical: LucideIcon will only have access to the icons provided closest to it in the tree.
:::
You can use the title input property to set the accessible name element on the SVG:
<svg lucideIcon="house" title="Go to dashboard"></svg>
This will result in the following output:
<svg class="lucide lucide-house" ...>
<title>Go to dashboard</title>
<!-- SVG paths -->
</svg>
You can pass additional props to adjust the icon appearance.
| name | type | default |
|---|---|---|
size | number | 24 |
color | string | currentColor |
strokeWidth | number | 2 |
absoluteStrokeWidth | boolean | false |
<svg lucideHouse size="48" color="red" strokeWidth="1"></svg>
You can use provideLucideConfig to configure the default property values as defined above:
import { ApplicationConfig } from '@angular/core';
import { provideLucideConfig } from '@lucide/angular';
export const appConfig: ApplicationConfig = {
providers: [
// ...
provideLucideConfig({
strokeWidth: 1.5
}),
]
};
Icons can also be styled by using custom CSS classes:
<svg lucideHousePlus class="my-icon"></svg>
svg.my-icon {
width: 12px;
height: 12px;
stroke-width: 3;
}
Lucide lab is a collection of icons that are not part of the Lucide main library.
While they aren't provided as standalone components, they can be still be passed to the LucideIcon component the same way as official icons:
<!-- Directly as LucideIconData: -->
<svg [lucideIcon]="CoconutIcon"></svg>
<!-- As a provided icon by name: -->
<svg lucideIcon="coconut"></svg>
import { provideLucideIcons } from '@lucide/angular';
import { coconut } from '@lucide/lab';
@Component({
templateUrl: './foobar.html',
// For using by name via provider:
providers: [provideLucideIcons({ coconut })],
imports: [LucideIcon]
})
export class Foobar {
// For passing directly as LucideIconData:
readonly CoconutIcon = coconut;
}
If using per-icon-components:
If using the dynamic component:
provideLucideIcons() if using string names@lucide/angular and not the legacy packageMake sure you're importing from @lucide/angular and not lucide-angular.
Ensure provideLucideConfig() is used at the right level.
Migrating from lucide-angular? Read our comprehensive migration guide.