Mit diesem Paket können Sie die Tabler -Symbole in Ihren Winkelanwendungen verwenden. Tabler-Symbole sind eine Reihe von kostenlosen MIT-lizenzierten hochwertigen SVG-Icons, die Sie in Ihren Webprojekten verwenden können. Jedes Symbol ist auf einem 24x24 -Raster und einem 2px -Schlaganfall ausgelegt.
1. Installieren Sie das Paket
npm install angular-tabler-icons
# or
yarn add angular-tabler-icons Wenn Sie eigenständige Komponenten verwenden, verwenden Sie die provideTablerIcons()
import { Component } from '@angular/core' ;
import { TablerIconComponent , provideTablerIcons } from 'angular-tabler-icons' ;
import {
IconNumber123 ,
IconAdOff ,
IconHeartFilled ,
} from 'angular-tabler-icons/icons' ;
@ Component ( {
selector : 'app-standalone' ,
imports : [ TablerIconComponent ] ,
/**
* Provide the icons which you want to use in this component.
*/
providers : [
provideTablerIcons ( {
IconNumber123 ,
IconAdOff ,
IconHeartFilled ,
} ) ,
] ,
,
} )
export class StandaloneComponent { } < fieldset >
< legend > 123 </ legend >
< i-tabler name =" number-123 " > </ i-tabler >
</ fieldset >
< fieldset >
< legend > 123 (style, big) </ legend >
< i-tabler name =" number-123 " style =" height: 60px; width: 60px; " > </ i-tabler >
</ fieldset >
< fieldset >
< legend > ad-off (style, red) </ legend >
< i-tabler name =" ad-off " style =" color: red; " > </ i-tabler >
</ fieldset >
< fieldset >
< legend > heart-filled (style, red) </ legend >
< i-tabler name =" heart-filled " style =" color: red; " > </ i-tabler >
</ fieldset > Liste der verfügbaren Symbole: https://tabler.io/icons
Diese Version enthält Tabler -Symbole v3.26.0 , siehe ChangeLog, um zu wissen, welche Symbole verfügbar sind.
Jedes Symbol kann separat mit CSS gestaltet werden:
< i-tabler name =" camera " class =" big fill-red stroke-blue thin " > </ i-tabler > . big {
height : 50 px ;
width : 50 px ;
}
. fill-red {
fill : red;
}
. stroke-blue {
color : blue;
}
. thin {
stroke-width : 1 px ;
}Einige Optionen stehen zur Konfiguration des Moduls zur Verfügung:
import { environment } from "../environments/environment" ;
import { TablerIconsModule } from "angular-tabler-icons" ;
import * as TablerIcons from "angular-tabler-icons/icons" ;
@ NgModule ( {
imports : [
TablerIconsModule . pick ( TablerIcons , {
// Ignore warnings, such as "Tabler Icon not found", for example:
// ignoreWarnings: environment.production,
ignoreWarnings : true ,
} ) ,
] ,
exports : [ TablerIconsModule ] ,
} )
export class IconsModule { } Sie können alle Symbole gleichzeitig importieren, indem Sie Folgendes ausführen. Denken Sie jedoch daran, dass alle Symbole auf diesem Anwendungsbündel enden. Dies ist zwar möglicherweise kein Problem für das Prototyping, aber es wird nicht für eine Anwendung empfohlen, die Sie freigeben möchten .
import { TablerIconsModule } from "angular-tabler-icons" ;
import * as TablerIcons from "angular-tabler-icons/icons" ;
@ NgModule ( {
imports : [ TablerIconsModule . pick ( TablerIcons ) ] ,
exports : [ TablerIconsModule ] ,
} )
export class IconsModule { }1. Generieren Sie ein Modul, um die Symbole zu hosten, die Sie importieren,
ng generate module icons2. Importieren von Vermögenswerten
Sie müssen importieren:
<i-tabler> -Komponente enthältWir haben dies in Iconsmodule für Modularität eingestellt. Siehe Beispiel unten:
Datei: icon.module.ts
import { NgModule } from "@angular/core" ;
import { TablerIconsModule } from "angular-tabler-icons" ;
import { IconCamera , IconHeart , IconBrandGithub } from "angular-tabler-icons/icons" ;
// Select some icons (use an object, not an array)
const icons = {
IconCamera ,
IconHeart ,
IconBrandGithub ,
} ;
@ NgModule ( {
imports : [ TablerIconsModule . pick ( icons ) ] ,
exports : [ TablerIconsModule ] ,
} )
export class IconsModule { }
// NOTES:
// 1. We add TablerIconsModule to the 'exports', since the <i-tabler> component will be used in templates of parent module
// 2. Don't forget to pick some icons using TablerIconsModule.pick({ ... })3.. Importikonsmodul
Wenn Sie Ngmodules verwenden, importieren Sie es so:
import { NgModule } from "@angular/core" ;
import { MyComponent } from "./my/my.component" ;
import { IconsModule } from "./icons.module" ;
@ NgModule ( {
declarations : [ MyComponent ] ,
imports : [
IconsModule , // <--- Here
] ,
} )
export class MyModule { }4. Verwenden Sie es in der Vorlage
Verwenden Sie nach dem Importieren des Iconsmoduls in Ihrer Funktion oder dem gemeinsamen Modul die Symbole wie folgt:
< i-tabler name =" camera " > </ i-tabler >
< i-tabler name =" heart " style =" color: red; " > </ i-tabler >
< i-tabler name =" heart-filled " style =" color: red; " > </ i-tabler >
< i-tabler name =" brand-github " class =" someclass " > </ i-tabler > | Eckig | Angular-Tabler-ICons |
|---|---|
| 18 & 19 | 3.22.0+ |
| 17 | 2.40.1+ |
| 16 | 2.21.1+ |
| 15 | 1.117.1+ |
| 14 | 1.72.1+ |
| 13 | 1.53.1+ |
| 12 | 1.41.3+ |
| 11 | 1.41.0+ |
Fühlen Sie sich frei, Probleme zu melden oder zu diesem Projekt beizutragen! Hier sind nur wenige Tipps zu Beginn:
yarn lib:generate # generate components from Tabler Icons
yarn lib:build # build angular library Automatic PR on Tabler Icons Release mit neuer Tabler -Symbole (z. B. 2.40.0 ) aus. Dieser Workflow erstellt automatisch eine neue Pull -Anfrage. Das Paket wird automatisch umgebaut und veröffentlicht, wobei das GitHub Action Workflow Build and Publish package .
Vielen Dank an diese wunderbaren Menschen (Emoji -Schlüssel):
Pierre ? | Arjen Althoff ? | Jan Schab |
Dieses Projekt folgt der All-Contributors-Spezifikation. Beiträge jeglicher Art willkommen!