2021-10-01 09:19:36 +02:00
|
|
|
# Lucide Angular
|
|
|
|
|
|
|
|
|
|
Implementation of the lucide icon library for angular applications.
|
|
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
2022-10-27 08:19:45 +02:00
|
|
|
```sh
|
2021-10-01 09:19:36 +02:00
|
|
|
yarn add lucide-angular
|
2022-10-27 08:19:45 +02:00
|
|
|
```
|
2021-10-01 09:19:36 +02:00
|
|
|
|
2022-10-27 08:19:45 +02:00
|
|
|
or
|
2021-10-01 09:19:36 +02:00
|
|
|
|
2022-10-27 08:19:45 +02:00
|
|
|
```sh
|
2021-10-01 09:19:36 +02:00
|
|
|
npm install lucide-angular
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## How to use
|
|
|
|
|
|
|
|
|
|
There are three ways for use this library.
|
|
|
|
|
|
|
|
|
|
### Method 1: createElement
|
|
|
|
|
|
|
|
|
|
After install `lucide-angular` change content of file `app.component.html` and `app.component.ts`.
|
|
|
|
|
|
2022-10-27 08:19:45 +02:00
|
|
|
```html
|
2021-10-01 09:19:36 +02:00
|
|
|
<!-- app.component.html -->
|
|
|
|
|
<div id="lucide-icon"></div>
|
|
|
|
|
```
|
|
|
|
|
|
2022-10-27 08:19:45 +02:00
|
|
|
```js
|
2021-10-01 09:19:36 +02:00
|
|
|
// app.component.ts
|
|
|
|
|
|
|
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
|
import { createElement } from 'lucide-angular';
|
|
|
|
|
import { Activity } from 'lucide-angular/icons';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-root',
|
|
|
|
|
templateUrl: './app.component.html',
|
|
|
|
|
styleUrls: ['./app.component.css']
|
|
|
|
|
})
|
|
|
|
|
export class AppComponent implements OnInit {
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
|
const div = document.getElementById('lucide-icon');
|
|
|
|
|
const elm = createElement(Activity);
|
|
|
|
|
elm.setAttribute('color', 'red'); // or set `width`, `height`, `fill`, `stroke-width`, ...
|
|
|
|
|
|
|
|
|
|
if (div) {
|
|
|
|
|
div.appendChild(elm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2022-10-27 08:19:45 +02:00
|
|
|
### Method 2: User **Tag** with **name** property
|
2021-10-01 09:19:36 +02:00
|
|
|
|
|
|
|
|
After install `lucide-angular` change content of file `app.component.html`, `app.component.ts`, `app.component.css` and `app.module.ts`.
|
|
|
|
|
|
2022-10-27 08:19:45 +02:00
|
|
|
```js
|
2021-10-01 09:19:36 +02:00
|
|
|
// app.module.ts
|
|
|
|
|
import { NgModule } from '@angular/core';
|
|
|
|
|
import { BrowserModule } from '@angular/platform-browser';
|
|
|
|
|
|
|
|
|
|
import { AppRoutingModule } from './app-routing.module';
|
|
|
|
|
import { AppComponent } from './app.component';
|
|
|
|
|
import { LucideAngularModule, AlarmCheck, Edit } from 'lucide-angular';
|
|
|
|
|
|
|
|
|
|
@NgModule({
|
2022-10-27 08:19:45 +02:00
|
|
|
declarations: [AppComponent],
|
2021-10-01 09:19:36 +02:00
|
|
|
imports: [
|
|
|
|
|
BrowserModule,
|
|
|
|
|
AppRoutingModule,
|
2022-10-27 08:19:45 +02:00
|
|
|
LucideAngularModule.pick({ AlarmCheck, Edit }) // add all of icons that is imported.
|
2021-10-01 09:19:36 +02:00
|
|
|
],
|
|
|
|
|
providers: [],
|
|
|
|
|
bootstrap: [AppComponent]
|
|
|
|
|
})
|
2022-10-27 08:19:45 +02:00
|
|
|
export class AppModule {}
|
2021-10-01 09:19:36 +02:00
|
|
|
```
|
|
|
|
|
|
2022-10-27 08:19:45 +02:00
|
|
|
```html
|
2021-10-01 09:19:36 +02:00
|
|
|
<!-- app.component.html -->
|
|
|
|
|
<lucide-icon name="alarm-check" class="myicon"></lucide-icon>
|
|
|
|
|
<lucide-icon name="edit" class="myicon"></lucide-icon>
|
|
|
|
|
```
|
|
|
|
|
|
2022-10-27 08:19:45 +02:00
|
|
|
### Method 3: User **Tag** with **img** property
|
2021-10-01 09:19:36 +02:00
|
|
|
|
|
|
|
|
After install `lucide-angular` change content of file `app.component.html`, `app.component.ts`, `app.component.css` and `app.module.ts`.
|
|
|
|
|
|
2022-10-27 08:19:45 +02:00
|
|
|
```js
|
2021-10-01 09:19:36 +02:00
|
|
|
// app.module.ts
|
|
|
|
|
import { NgModule } from '@angular/core';
|
|
|
|
|
import { BrowserModule } from '@angular/platform-browser';
|
|
|
|
|
|
|
|
|
|
import { AppRoutingModule } from './app-routing.module';
|
|
|
|
|
import { AppComponent } from './app.component';
|
|
|
|
|
import { LucideAngularModule } from 'lucide-angular';
|
|
|
|
|
|
|
|
|
|
@NgModule({
|
2022-10-27 08:19:45 +02:00
|
|
|
declarations: [AppComponent],
|
|
|
|
|
imports: [BrowserModule, AppRoutingModule, LucideAngularModule.pick({})],
|
2021-10-01 09:19:36 +02:00
|
|
|
providers: [],
|
|
|
|
|
bootstrap: [AppComponent]
|
|
|
|
|
})
|
2022-10-27 08:19:45 +02:00
|
|
|
export class AppModule {}
|
2021-10-01 09:19:36 +02:00
|
|
|
```
|
|
|
|
|
|
2022-10-27 08:19:45 +02:00
|
|
|
```xml
|
2021-10-01 09:19:36 +02:00
|
|
|
<!-- app.component.html -->
|
|
|
|
|
<lucide-icon [img]="ico1" class="myicon"></lucide-icon>
|
|
|
|
|
<lucide-icon [img]="ico2" class="myicon"></lucide-icon>
|
|
|
|
|
```
|
|
|
|
|
|
2022-10-27 08:19:45 +02:00
|
|
|
```js
|
2021-10-01 09:19:36 +02:00
|
|
|
// app.component.ts
|
|
|
|
|
import { Component } from '@angular/core';
|
|
|
|
|
import { Airplay, Circle } from 'lucide-angular';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-root',
|
|
|
|
|
templateUrl: './app.component.html',
|
|
|
|
|
styleUrls: ['./app.component.css']
|
|
|
|
|
})
|
|
|
|
|
export class AppComponent {
|
|
|
|
|
ico1 = Airplay;
|
|
|
|
|
ico2 = Circle;
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Notes
|
|
|
|
|
|
|
|
|
|
### Import all icons
|
|
|
|
|
|
|
|
|
|
In `Method 2`: import all icons in `app.module.ts` by:
|
|
|
|
|
|
2022-10-27 08:19:45 +02:00
|
|
|
```js
|
2021-10-01 09:19:36 +02:00
|
|
|
|
|
|
|
|
import { icons } from 'lucide-angular/icons';
|
|
|
|
|
|
|
|
|
|
LucideAngularModule.pick(icons)
|
|
|
|
|
|
|
|
|
|
...
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Tags
|
|
|
|
|
|
|
|
|
|
You can use the following tags instead of `lucide-icon`:
|
|
|
|
|
|
|
|
|
|
- lucide-angular
|
|
|
|
|
- i-lucide
|
|
|
|
|
- span-lucide
|
|
|
|
|
|
|
|
|
|
All of the above are the same
|