Angular PrimeNG Messages Animation Configuration
Last Updated :
26 Apr, 2025
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. It provides a lot of templates, components, theme design, an extensive icon library, and much more. In this article, we will see the Angular PrimeNG Messages Animation Configuration.
The Messages component is used to display alerts inline. They are used to provide alerts to users within the webpage only providing a smoother experience and replacing the default alerts. The Messages Animation Configuration allows configuring the default animation.
Messages Animation Configuration properties:
- showTransitionOptions: Here we put the animation displayed when we show a message. The default value is 300ms ease-out.
- hideTransitionOptions: Here we put the animation displayed when we hide a message. The default value is 200ms cubic-bezier(0.86, 0, 0.07, 1).
Syntax:
<p-messages
[showTransitionOptions]="'..."
[hideTransitionOptions]="'...'">
</p-messages>
Creating Angular application & Module Installation:
Step 1: Create an Angular application using the following command.
ng new geeks_angular
Step 2: After creating your project folder i.e. geeks_angular, move to it using the following command.
cd geeks_angular
Step 3: Install PrimeNG in your given directory.
npm install primeng --save
npm install primeicons --save
Project Structure: The project structure will look like the following:
Steps to run the above file: Run the below command
ng serve --save
Example 1: Below is the example code that illustrates the use of Messages Animation Configuration in Angular PrimeNG. In the following example, we have a different animation when the message appears.
HTML
< h1 style = "color: green; text-align: center;" >
GeeksforGeeks
</ h1 >
< h3 >Angular PrimeNG Messages Animation Configuration</ h3 >
< button
type = "button"
pButton
(click)="showViaService()"
label = "Add Message" >
</ button >
< p-messages
[showTransitionOptions]="'1s ease-in-out'"
[hideTransitionOptions]="'0.5s linear'">
</ p-messages >
|
Javascript
import { Component } from "@angular/core" ;
import { Message, MessageService } from "primeng/api" ;
import { PrimeNGConfig } from "primeng/api" ;
@Component({
selector: "app-root" ,
templateUrl: "./app.component.html" ,
providers: [MessageService]
})
export class AppComponent {
msgs1: Message[];
msgs2: Message[];
constructor(
private messageService: MessageService,
private primengConfig: PrimeNGConfig
) {}
ngOnInit() {
this .primengConfig.ripple = true ;
}
showViaService() {
this .messageService.add({
severity: "success" ,
summary: "Service Message" ,
detail: "Via MessageService"
});
}
}
|
Javascript
import { NgModule } from "@angular/core" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { FormsModule } from "@angular/forms" ;
import { HttpClientModule } from "@angular/common/http" ;
import { BrowserAnimationsModule }
from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { MessagesModule } from "primeng/messages" ;
import { MessageModule } from "primeng/message" ;
import { ButtonModule } from "primeng/button" ;
import { InputTextModule } from "primeng/inputtext" ;
import { RippleModule } from "primeng/ripple" ;
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
MessagesModule,
MessageModule,
ButtonModule,
InputTextModule,
RippleModule,
FormsModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {}
|
Output:
Example 2: Below is another example code that illustrates the use of Messages Animation Configuration in Angular PrimeNG. In the following example, we have turned off the animation.
HTML
< h1 style = "color: green; text-align: center;" >
GeeksforGeeks
</ h1 >
< h3 >Angular PrimeNG Messages Animation Configuration</ h3 >
< button
type = "button"
pButton
(click)="showViaService()"
label = "Add Message" >
</ button >
< p-messages
[showTransitionOptions]="'0s'"
[hideTransitionOptions]="'0s'">
</ p-messages >
|
Javascript
import { Component } from "@angular/core" ;
import { Message, MessageService } from "primeng/api" ;
import { PrimeNGConfig } from "primeng/api" ;
@Component({
selector: "app-root" ,
templateUrl: "./app.component.html" ,
providers: [MessageService]
})
export class AppComponent {
msgs1: Message[];
msgs2: Message[];
constructor(
private messageService: MessageService,
private primengConfig: PrimeNGConfig
) {}
ngOnInit() {
this .primengConfig.ripple = true ;
}
showViaService() {
this .messageService.add({
severity: "success" ,
summary: "Service Message" ,
detail: "Via MessageService"
});
}
}
|
Javascript
import { NgModule } from "@angular/core" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { FormsModule } from "@angular/forms" ;
import { HttpClientModule } from "@angular/common/http" ;
import { BrowserAnimationsModule }
from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { MessagesModule } from "primeng/messages" ;
import { MessageModule } from "primeng/message" ;
import { ButtonModule } from "primeng/button" ;
import { InputTextModule } from "primeng/inputtext" ;
import { RippleModule } from "primeng/ripple" ;
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
MessagesModule,
MessageModule,
ButtonModule,
InputTextModule,
RippleModule,
FormsModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {}
|
Output:
Reference: https://primefaces.org/primeng/messages
Similar Reads
Angular PrimeNG Messages Severities
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. This article will show us how to use the Messages Severities in Angular PrimeNG. We will also learn
3 min read
Angular PrimeNG Messages Dynamic
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 see how to use the Messages Dynamic in Angular PrimeNG. We will also learn
3 min read
Angular PrimeNG Message Service
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. This article will show us how to use the Messages Service in Angular PrimeNG. We will also learn abo
3 min read
Angular PrimeNG Messages Static Content
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 see the static content in Messages Component in Angular PrimeNG. The Messa
3 min read
Angular PrimeNG Messages Inline Message
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 see how to use the Messages Inline Message in Angular PrimeNG. We will also
3 min read
Angular PrimeNG Messages Array
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 see the Messages Array in Angular PrimeNG. The Messages component is used t
3 min read
Angular PrimeNG Messages Closable
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 see how to use the Messages Closable in Angular PrimeNG. We will also learn
3 min read
Angular PrimeNG Message Component
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 learn how to use the Message Component in Angular PrimeNG. We will also lea
3 min read
Angular PrimeNG Messages Animation Configuration
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. It provides a lot of templates, components, theme design, an extensive icon library, and much more.
4 min read
Angular PrimeNG Properties of Messages Component
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 learn how to use the Messages Properties in Angular PrimeNG. We will also l
4 min read