Getting Started with code | Angular
Install
- npm
- Yarn
- pnpm
npm install @dhl-official/angular-library
yarn add @dhl-official/angular-library
pnpm add @dhl-official/angular-library
Enable Custom Elements
To install the DHL User Interface Library into your Angular application, first enable custom element schemas within app.module.ts
.
Import CUSTOM_ELEMENTS_SCHEMA
from @angular/core
and add it to the schemas
array as shown below:
caution
Note the import of ComponentLibrary
from @dhl-official/angular-library
replaces the import of ComponentModule
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { ComponentLibrary } from '@dhl-official/angular-library';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule
ComponentLibrary
],
providers: [],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule { }
Install Styles
To install the component styles, navigate to angular.json
and add the following to the styles
array:
"styles": [
"@dhl-official/tokens/index.css"
]
<dhl-button>Button</dhl-button>
Install Icons
{
"glob": "**/*",
"input": "./node_modules/@dhl-official/icons",
"output": "/assets/duil/icons"
}
<dhl-button icon="/assets/duil/icons/ICON_NAME.svg">Button with icon</dhl-button>