Angular PrimeNG Fieldset Properties
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 Properties in Angular PrimeNG.
Fieldset Component is a grouping component that takes a header along with some content associated with that header having a toggle feature.
Angular PrimeNG Fieldset Properties:
- legend: It is the header text of the fieldset. It is of string data type, the default value is null.
- toggleable: It specifies whether the content can be toggled by clicking the legend. It is of boolean data type, the default value is false.
- collapsed: It defines the default visibility state of the content. It is of boolean data type, the default value is false.
- style: It is an inline style of the fieldset. It is of string data type, the default value is null.
- styleClass: It is the style class of the fieldset. It is of string data type, the default value is null.
- transitionOptions: It is the transition option of the animation. It is of string data type, the default value is 400ms cubic-bezier(0.86, 0, 0.07, 1).
Creating Angular application & module Installation:
Step 1: To create an angular app, you need to install the angular command line interface through the npm command.
npm install -g angular-cli
Step 2: Now we will create an angular project.
ng new project_name
Step 3: After creating your angular project, move into the folder to perform different operations.
cd project_name
Step 4: After creating the Angular application, Install the required module using the following command:
npm install primeng --save npm install primeicons --save
Project Structure: After running the commands mentioned in the above steps, it will look like the following:
- Step to Run Application: Run the application using the following command from the root directory of the project:
ng serve --open
Example 1: We are creating a UI that shows Angular PrimeNG Fieldset Properties.
- app.component.html
HTML
< div style = "margin:100px;" > < h1 style = "color: green" >w3wiki</ h1 > < h3 >Angular PrimeNG Fieldset Properties</ h3 > < p-fieldset legend = "DSA - Self Paced Course" [toggleable]="true" [collapsed]="true" [style]="{'backgroundColor':'black', 'color':'green'}"> < p > Most popular course on DSA trusted by over 75,000 students! Built with years of experience by industry experts and gives you a complete package of video lectures, practice problems, quizzes, discussion forums and contests. Start Today! </ p > </ p-fieldset >< br />< br /> < p-fieldset legend = "Complete Interview Preparation Course" [toggleable]="true" [collapsed]="true" [style]="{'backgroundColor':'black', 'color':'green'}"> < p > An interview-centric course designed to prepare you for the role of SDE for both product and service based companies. A placement preparation pack built with years of expertise. Prepare C++, Java, DSA, CS Theory concepts and much more! </ p > </ p-fieldset > </ div > |
- app.component.ts
Javascript
import { Component } from '@angular/core' ; @Component({ selector: 'my-app' , 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({ declarations: [ AppComponent ], imports: [ BrowserModule, FieldsetModule, BrowserAnimationsModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } |
Output:
Example 2: We are creating a UI that shows above mentioned Properties of Fieldset.
- app.component.html
HTML
< div style = "margin:100px;" > < h1 style = "color: green" >w3wiki</ h1 > < h3 >Angular PrimeNG Fieldset Properties</ h3 > < br /> < p-fieldset legend = "Hi Geek!" [toggleable]="true" transitionOptions = "1000ms" [style]="{'color':'green', 'text-align':'center'}"> < p > Welcome to Beginner For Beginner!< br /> Billions of Users, Millions of Articles Published, Thousands Got Hired by Top Companies and the numbers are still growing. </ p > </ p-fieldset > </ div > |
- app.component.ts
Javascript
import { Component } from '@angular/core' ; @Component({ selector: 'my-app' , 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({ declarations: [ AppComponent ], imports: [ BrowserModule, FieldsetModule, BrowserAnimationsModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } |
Output:
Reference: https://primefaces.org/primeng/fieldset
Contact Us