Angular PrimeNG Dynamic Dialog Styling
Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will know how to use Dynamic Dialog Styling in Angular PrimeNG.
Dialogs are containers to display content in an overlay window & can be dynamically created with any component as the content with the help of DialogService.
Angular PrimeNG Dynamic Dialog Styling: This component helps to make the interactive Dialog by implementing the different stylings provided by Angular PrimeNG.
- p-dialog: It is a container element.
- p-dynamicdialog: It is also a container element.
- p-dialog-titlebar: It is the header’s container.
- p-dialog-title: It is a header element.
- p-dialog-titlebar-icon: It is an icon container inside the header
- p-dialog-titlebar-close: It is the close icon element.
- p-dialog-content: It is the container element.
- p-dialog-footer: It is the footer element.
Creating Angular application & module installation:
Step 1: Create an Angular application using the following command.
ng new appname
Step 2: After creating your project folder i.e. appname, move to it using the following command.
cd appname
Step 3: Install PrimeNG in your given directory.
npm install primeng --save npm install primeicons --save
Project Structure: It will look like the following:

Steps to run the application: Run the below command to see the output
ng serve --save
Example 1: Below is the example code that illustrates the use of Angular PrimeNG Dynamic Dialog Styling.
- app.component.html:
HTML
< h1 style = "color: green" >GeeksforGeeks</ h1 > < h5 >Angular PrimeNG Dialog Styling</ h5 > < p-button (click)="GFG()" icon = "pi pi-check" styleClass = "p-button-success" label = "Click here Geek!" > </ p-button > < p-dialog header = "GeeksforGeeks" [(visible)]="gfg" [modal]="true" [draggable]="true" [resizable]="true" [style]="{width: '75vw'}" [baseZIndex]="10000"> < p > Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. </ p > < ng-template pTemplate = "footer" > < p-button icon = "pi pi-check" (click)=" gfg = false " label = "Confirm" styleClass = "p-button-text" > </ p-button > < p-button icon = "pi pi-times" (click)=" gfg = false " label = "Reject" > </ p-button > </ ng-template > </ p-dialog > |
- app.component.ts:
Javascript
import { Component } from '@angular/core' ; import { PrimeNGConfig } from 'primeng/api' ; @Component({ selector: 'app-root' , templateUrl: './app.component.html' , styleUrls: [ './app.component.css' ] }) export class AppComponent { constructor(private primengConfig: PrimeNGConfig) {} gfg: boolean; ngOnInit() { this .primengConfig.ripple = true ; } GFG() { this .gfg = true ; } } |
- app.module.ts:
Javascript
import { NgModule } from '@angular/core' ; import { BrowserAnimationsModule } from '@angular/platform-browser/animations' ; import { AppComponent } from './app.component' ; import { DialogModule } from 'primeng/dialog' ; import { ButtonModule } from 'primeng/button' ; @NgModule({ imports: [ BrowserAnimationsModule, DialogModule, ButtonModule ], declarations: [ AppComponent ], bootstrap: [ AppComponent ] }) export class AppModule { } |
- app.component.css:
CSS
:host ::ng-deep .p-dialog{ border : 2px dashed red ; padding : 2px ; } |
Output:

Example 2: Below is another example code that illustrates the use of Angular PrimeNG Dynamic Dialog Styling.
- app.component.html:
HTML
< h1 style = "color: green" >GeeksforGeeks</ h1 > < h5 >Angular PrimeNG Dialog Styling</ h5 > < p-button (click)="GFG()" icon = "pi pi-code" styleClass = "p-button-danger" label = "Click me Geek!" > </ p-button > < p-dialog position = "top" header = "GeeksforGeeks" [(visible)]="gfg"> < p >I am Top!</ p > </ p-dialog > < p-dialog position = "bottom" header = "GeeksforGeeks" [(visible)]="gfg"> < p >I am Bottom!</ p > </ p-dialog > < p-dialog position = "left" header = "GeeksforGeeks" [(visible)]="gfg"> < p >I am Left!</ p > </ p-dialog > < p-dialog position = "right" header = "GeeksforGeeks" [(visible)]="gfg"> < p >I am Right!</ p > </ p-dialog > |
- app.component.ts:
Javascript
import { Component } from '@angular/core' ; import { PrimeNGConfig } from 'primeng/api' ; @Component({ selector: 'app-root' , templateUrl: './app.component.html' , styleUrls: [ './app.component.css' ] }) export class AppComponent { constructor(private primengConfig: PrimeNGConfig) {} gfg: boolean; ngOnInit() { this .primengConfig.ripple = true ; } GFG() { this .gfg = true ; } } |
- app.module.ts:
Javascript
import { NgModule } from '@angular/core' ; import { BrowserAnimationsModule } from '@angular/platform-browser/animations' ; import { AppComponent } from './app.component' ; import { DialogModule } from 'primeng/dialog' ; import { ButtonModule } from 'primeng/button' ; @NgModule({ imports: [ BrowserAnimationsModule, DialogModule, ButtonModule ], declarations: [ AppComponent ], bootstrap: [ AppComponent ] }) export class AppModule { } |
- app.component.css:
CSS
:host ::ng-deep .p-dialog{ border : 2px dashed red ; padding : 2px ; box-shadow: 10px 8px 10px #1ac53f ; } |
Output:

Reference: https://primefaces.org/primeng/dialog