Angular PrimeNG Fieldset 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. In this article, we will see how to use the different available Fieldset Animation Configuration in Angular PrimeNG.
The Fieldset Component is a grouping component that takes a header along with some content associated with that header having a toggle feature. The transitionOptions property, which by default has the value 400ms cubic-bezier(0.86, 0, 0.07, 1), allows the toggle animation transition to be changed.
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 Fieldset Animation Configuration.
- app.component.html:
HTML
< h1 style = "color: green" >w3wiki</ h1 > < h3 >Angular PrimeNG Fieldset Animation Configuration</ h3 > < p-fieldset legend = "Hi Beginner!" [toggleable]="true" transitionOptions = "1500ms" [style]="{ color: 'green', 'text-align': 'center' }"> < p > Welcome to Beginner For Beginner! Billions of Users, Millions of Articles Published, Thousands Got Hired by Top Companies and the numbers are still growing. </ p > </ p-fieldset > |
- app.cmponent.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 { BrowserModule } from '@angular/platform-browser' ; import { BrowserAnimationsModule } from '@angular/platform-browser/animations' ; import { AppComponent } from './app.component' ; import { FieldsetModule, } from 'primeng/fieldset' ; @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, FieldsetModule, ], declarations: [ AppComponent ], bootstrap: [ AppComponent ] }) export class AppModule { } |
Output:
Example 2: Below is another example code that illustrates the use of Angular PrimeNG Fieldset Animation Configuration using Templates and some styling.
- app.component.html:
HTML
< h1 style = "color: green" >w3wiki</ h1 > < h3 >Angular PrimeNG Fieldset Animation Configuration</ h3 > < p-fieldset [toggleable]="true" transitionOptions = "1500ms" [style]="{ 'text-align': 'center' }"> < ng-template pTemplate = "header" > w3wiki </ ng-template > < ng-template pTemplate = "content" > < p > Welcome to Beginner For Beginner! Billions of Users, Millions of Articles Published, Thousands Got Hired by Top Companies and the numbers are still growing. </ p > </ ng-template > </ p-fieldset > |
- app.cmponent.ts:
Javascript
import { Component } from '@angular/core' ; @Component({ selector: 'app-root' , templateUrl: './app.component.html' , styleUrls: [ './app.component.css' ], }) export class AppComponent {} |
- app.module.ts:
Javascript
import { NgModule } from '@angular/core' ; import { BrowserModule } from '@angular/platform-browser' ; import { BrowserAnimationsModule } from '@angular/platform-browser/animations' ; import { AppComponent } from './app.component' ; import { FieldsetModule, } from 'primeng/fieldset' ; @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, FieldsetModule, ], declarations: [ AppComponent ], bootstrap: [ AppComponent ] }) export class AppModule { } |
- app.component.css:
CSS
:host ::ng-deep .p-fieldset-content { color : green ; background-color : aliceblue; } :host ::ng-deep .p-fieldset-toggleable{ rotate: 10 deg; margin-top : 100px ; } |
Output:
Reference: https://primefaces.org/primeng/fieldset
Contact Us