Angular PrimeNG Dialog Responsive
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 Dialog Responsive in Angular PrimeNG. We will also learn about the properties along with their syntaxes that will be used in the code.
Dialog component is used to make a component containing some content to display in an overlay window. With the breakpoints option, dialogue width may be modified in accordance with screen size. Breakpoints should have an object literal as their value, with keys representing the largest screen sizes and values representing the widths of the dialog.
Angular PrimeNG Dialog Responsive Properties:
- header: It is the title text of the dialog. It is of string data type, the default value is null.
- visible: It specifies the visibility of the dialog. It is of the boolean data type, the default value is false.
- style: It is used to set the inline style of the component. It is of object data type, the default value is null.
- styleClass: It is used to set the style class of the component. It is of string data type, the default value is null.
- breakpoints: It is the object literal to define widths per screen size. It is of object data type, default Value is null.
- resizable: It enables resizing of the content. It is of boolean data type, the default value is true.
- draggable: It enables dragging to change the position using a header. It is of the boolean data type, the default value is true.
Syntax:
<p-dialog header="...." [style]="{width: '...vw'}" [(visible)]="..." [breakpoints]="{...}" [draggable]="..." [resizable]="..."> </p-dialog> <p-button (click)="..." label="...."> </p-button>
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:
- Run the below command to see the output:
ng serve --open
Example 1: Below is the code example that illustrates the use of Angular PrimeNG Dialog Responsive using short content.
app.component.html
< div style = "text-align: center" > < h2 style = "color: green" >GeeksforGeeks</ h2 > < h5 >Angular PrimeNG Dialog Responsive</ h5 > < p-dialog header = "GeeksforGeeks" [(visible)]="BasicShow" [style]="{width: '30vw'}" [breakpoints]=" { '900px': '50vw', '600px': '100vw' }" [style]="{width: '50vw'}"> < p > Angular PrimeNG is a framework used with angular to create components with great styling this framework is very easy to use and is used to make responsive websites. This article will show us how to use the Dialog Basic in Angular PrimeNG. </ p > < ng-template pTemplate = "footer" > < p-button (click)=" BasicShow = false " label = "Accept" styleClass = "p-button-success" > </ p-button > < p-button (click)=" BasicShow = false " label = "Reject" styleClass = "p-button-danger" > </ p-button > </ ng-template > </ p-dialog > < p-button (click)="showDialog()" label = "Short Content Modal" > </ p-button > </ div > |
app.component.ts
import { Component } from "@angular/core" ; import { PrimeNGConfig } from "primeng/api" ; @Component({ selector: "app-root" , templateUrl: "./app.component.html" , styles: [], }) export class AppComponent { constructor(private primengConfig: PrimeNGConfig) {} ngOnInit() { this .primengConfig.ripple = true ; } BasicShow: boolean = false ; showDialog() { this .BasicShow = true ; } } |
app.module.ts
import { NgModule } from '@angular/core' ; import { BrowserModule } from '@angular/platform-browser' ; import { BrowserAnimationsModule } from '@angular/platform-browser/animations' ; import { AppComponent } from './app.component' ; import { DialogModule } from 'primeng/dialog' ; import { ButtonModule } from 'primeng/button' ; @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, DialogModule, ButtonModule ], declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule { } |
Output:

Example 2: Below is another code example that illustrates Angular PrimeNG Dialog Responsive using long content.
app.component.html
< div style = "text-align: center" > < h2 style = "color: green" >GeeksforGeeks</ h2 > < h5 >Angular PrimeNG Dialog Responsive</ h5 > < p-dialog header = "GeeksforGeeks" [(visible)]="BasicShow" [style]="{width: '30vw'}" [breakpoints]=" { '800px': '30vw', '650px': '100vw' }" [style]="{width: '50vw'}"> < p > Angular PrimeNG is a framework used with angular to create components with great styling this framework is very easy to use and is used to make responsive websites. This article will show us how to use the Dialog Basic in Angular PrimeNG. Angular PrimeNG is a framework used with angular to create components with great styling this the the framework is very easy to use and is used to make responsive websites. </ p > < p > Angular PrimeNG is a framework used with angular to create components with great styling this framework is very easy to use and is used to make responsive websites. This article will show us how to use the Dialog Basic in Angular PrimeNG. Angular PrimeNG is a framework used with angular to create components with great styling this the the framework is very easy to use and is used to make responsive websites. This article will show us how to use the Dialog Basic in Angular PrimeNG. Angular PrimeNG is a framework used with angular to create components with great styling this framework is very easy to use and is used to make responsive websites. This article will show us how to use the Dialog Basic in Angular PrimeNG. Angular PrimeNG is a the framework used with angular to create components with great styling, this framework is very easy to use and is used to make responsive websites. This the article will show us how to use the Dialog Basic in Angular PrimeNG. </ p > < p > Angular PrimeNG is a framework used with angular to create components with great styling this framework is very easy to use and is used to make responsive websites. This article will show us how to use the Dialog Basic in Angular PrimeNG. Angular PrimeNG is a framework used with angular to create components with great styling this the the framework is very easy to use and is used to make responsive websites. This article will show us how to use the Dialog Basic in Angular PrimeNG. Angular PrimeNG is a framework used with angular to create components with great styling this framework is very easy to use and is used to make responsive websites. This article will show us how to use the Dialog Basic in Angular PrimeNG. Angular PrimeNG is a the framework used with angular to create components with great styling, this framework is very easy to use and is used to make responsive websites. This the article will show us how to use the Dialog Basic in Angular PrimeNG. </ p > < ng-template pTemplate = "footer" > < p-button (click)=" BasicShow = false " label = "Accept" styleClass = "p-button-success" > </ p-button > < p-button (click)=" BasicShow = false " label = "Reject" styleClass = "p-button-danger" > </ p-button > </ ng-template > </ p-dialog > < p-button (click)="showDialog()" label = "Short Content Modal" > </ p-button > </ div > |
app.component.ts
import { Component } from "@angular/core" ; import { PrimeNGConfig } from "primeng/api" ; @Component({ selector: "app-root" , templateUrl: "./app.component.html" , styles: [], }) export class AppComponent { constructor(private primengConfig: PrimeNGConfig) {} ngOnInit() { this .primengConfig.ripple = true ; } BasicShow: boolean = false ; showDialog() { this .BasicShow = true ; } } |
app.module.ts
import { NgModule } from "@angular/core" ; import { BrowserModule } from "@angular/platform-browser" ; import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ; import { AppComponent } from "./app.component" ; import { DialogModule } from "primeng/dialog" ; import { ButtonModule } from "primeng/button" ; @NgModule({ imports: [BrowserModule, BrowserAnimationsModule, DialogModule, ButtonModule], declarations: [AppComponent], bootstrap: [AppComponent], }) export class AppModule {} |
Output:

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