Open In App

Angular PrimeNG Panel Animation Configuration

Improve
Improve
Like Article
Like
Save
Share
Report

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 Panel Animation Configuration in Angular PrimeNG.

The Panel Component allows us to make an element containing a header and some content associated with that header. The transitionOptions property, which has a default value of 400ms cubic-bezier(0.86, 0, 0.07, 1), can be used to alter the transition of the toggle animation.

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 basic example demonstrating the use of Angular PrimeNG Panel Animation Configuration.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h3>Angular PrimeNG Panel Animation Configuration</h3>
  
<p-panel 
    header="GeeksforGeeks" 
    [toggleable]="true" 
    transitionOptions="1200ms">
    <p>
        Welcome to Geeks For Geeks! Billions of Users, 
          Millions of Articles Published, Thousands Got 
          Hired by Top Companies and the numbers are still
        growing.
    </p>
</p-panel>


  • app.component.ts:

Javascript




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
})
  
export class AppComponent { }


  • app.module.ts:

Javascript




import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } 
    from '@angular/platform-browser/animations';
import { AppComponent }   from './app.component';
import { PanelModule } from 'primeng/panel';
  
@NgModule({
    imports: [
        BrowserAnimationsModule,
        PanelModule,
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
  
export class AppModule { }


Output:

 

Example 2: Below is another example demonstrating the use of Angular PrimeNG Panel Animation Configuration using Templates.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h3>Angular PrimeNG Panel Animation Configuration</h3>
  
<p-panel [toggleable]="true" transitionOptions="1200ms">
    <ng-template pTemplate="icons">
        <button pButton class="p-panel-header-icon 
            p-link" icon="pi pi-code" 
            (click)="menu.toggle($event)">
        </button>
        <p-menu #menu [model]="gfg" [popup]="true"></p-menu>
    </ng-template>
    <ng-template pTemplate="header">
        GeeksforGeeks
    </ng-template>
    <ng-template pTemplate="content">
        <p>
            Welcome to Geeks For Geeks! Billions of Users, 
              Millions of Articles Published, Thousands Got 
              Hired by Top Companies and the numbers are still
            growing.
        </p>
    </ng-template>
    <ng-template pTemplate="footer">
        Copyright@GeeksforGeeks
    </ng-template>
</p-panel>


  • app.component.ts:

Javascript




import { Component } from '@angular/core';
import {MessageService} from 'primeng/api';
import {MenuItem} from 'primeng/api';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    providers: [MessageService]
})
  
export class AppComponent {
    gfg: MenuItem[];
  
    constructor(private messageService: MessageService) {}
  
    ngOnInit() {
        this.gfg = [
            {
                label: 'Languages',
                items: [
                {
                    label: 'C++'
                },
                {
                    label: 'Java'
                },
                {
                    label: 'Python'
                },
                {
                    label: 'C#'
                }
            ]},
        ];
    }
}


  • app.module.ts:

Javascript




import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } 
    from '@angular/platform-browser/animations';
import { AppComponent }   from './app.component';
import { PanelModule } from 'primeng/panel';
import { ButtonModule } from 'primeng/button';
import { MenuModule } from 'primeng/menu';
  
@NgModule({
  imports: [
    BrowserAnimationsModule,
    PanelModule,
    ButtonModule,
    MenuModule,
  ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
})
  
export class AppModule { }


Output:

 

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



Last Updated : 31 Jan, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads