ProductPromotion
Logo

Angular.JS

made by https://0x3d.site

GitHub - anedomansky/ngx-icon: An Angular component for displaying SVG icons.
An Angular component for displaying SVG icons. Contribute to anedomansky/ngx-icon development by creating an account on GitHub.
Visit Site

GitHub - anedomansky/ngx-icon: An Angular component for displaying SVG icons.

GitHub - anedomansky/ngx-icon: An Angular component for displaying SVG icons.

Ngx-icon

npm version

An Angular component for displaying SVG icons.

Features

  • display any SVG icon
  • add custom CSS to the SVG icons
  • automatic caching of previously added icons

Dependencies

ngx-icon Angular
current >= 16

Installation

npm install @anedomansky/ngx-icon

Setup

You have to add all your icons to the NgxIconService in order to display them. Please remove all height and width attributes from the <svg> element beforehand. Furthermore, you have to provide the HttpClient in your application.

main.ts:

import { NgxIconService } from "@anedomansky/ngx-icon";
import { provideHttpClient } from "@angular/common/http";
import { APP_INITIALIZER } from "@angular/core";
import { bootstrapApplication } from "@angular/platform-browser";

import { AppComponent } from "./app/app.component";

bootstrapApplication(AppComponent, {
  providers: [
    provideHttpClient(),
    {
      provide: APP_INITIALIZER,
      useFactory: (iconService: NgxIconService) => () => {
        iconService.addIcon("cart", "assets/");
        iconService.addIcon("camera", "assets/");
      },
      deps: [NgxIconService],
      multi: true,
    },
  ],
});

Usage

app.component.html:

<div class="app">
  <ngx-icon name="cart"></ngx-icon>
  <ngx-icon name="camera"></ngx-icon>
</div>

app.component.ts:

import { NgxIconComponent } from "@anedomansky/ngx-icon";
import { Component } from "@angular/core";

@Component({
  selector: "app-root",
  templateUrl: "./app.component.html",
  styleUrls: ["./app.component.scss"],
  standalone: true,
  imports: [NgxIconComponent],
})
export class AppComponent {}

Customization

You can alter the appearance (height, width, etc.) of the icons.

Additionally, there is a CSS Custom Property for the icon's height that can easily be updated.

app.component.scss:

.app ::ng-deep ngx-icon {
  --ngx-icon-size: 2rem;
}

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory