Open In App

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:

 



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:

Project Structure

ng serve --open

Example 1: We are creating a UI that shows Angular PrimeNG Fieldset Properties.




<div style="margin:100px;">
    <h1 style="color: green">GeeksforGeeks</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>




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




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.




<div style="margin:100px;">
    <h1 style="color: green">GeeksforGeeks</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 Geeks For Geeks!<br />
            Billions of Users, Millions of 
            Articles Published, Thousands Got Hired
            by Top Companies and the numbers are still
            growing.
        </p>
    </p-fieldset>
</div>




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




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


Article Tags :