Open In App

Angular PrimeNG Fieldset Regular

Last Updated : 19 Oct, 2022
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 Fieldset Regular in Angular PrimeNG. We will also learn about the properties, along with their syntaxes that will be used in the code.

The Fieldset Component is a grouping component that takes a header along with some content associated with that header having a toggle feature.

Syntax:

<p-fieldset 
   legend="....">
   <p>....</p>
</p-fieldset>

 

Angular PrimeNG Fieldset Regular Properties:

  • legend: It is the header text of the field set. It is of string data type, the default value is null.

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:

ng serve --open

Example 1: Below is the basic example demonstrating the use of Angular PrimeNG Fieldset Regular.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>
   Angular PrimeNG Fieldset Regular
</h5>
  
<p-fieldset legend="GeeksforGeeks">
    <p>
       Welcome to GeeksforGeeks.
       It is a Computer Science
       portal for all Geeks.
    </p>
</p-fieldset>


  • app.component.ts:

Javascript




import { Component } from '@angular/core';
  
@Component({
   selector: 'app-root',
   templateUrl: './app.component.html',
   providers: [],
})
  
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 that demonstrates using Angular PrimeNG Fieldset Regular using an image.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Fieldset Regular</h5>
  
<p-fieldset legend="GeeksforGeeks">
    <p>
       <img alt="gfg" height="200px" src=
    </p>
</p-fieldset>


  • app.component.ts:

Javascript




import { Component } from '@angular/core';
  
@Component({
   selector: 'app-root',
   templateUrl: './app.component.html',
   providers: [],
})
  
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:

 

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



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads