Angular PrimeNG Fieldset Custom Legend
Last Updated :
09 Nov, 2022
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 different Fieldset Custom Legend 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. You can design your own heading using the header template. Instead of using the legend property, you can use the template to create custom heading content.
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
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 Custom Legend.
HTML
< div style = "margin:100px;" >
< h1 style = "color: green" >GeeksforGeeks</ h1 >
< h3 >Angular PrimeNG Fieldset Custom Legend</ h3 >
< br />
< p-fieldset >
< ng-template pTemplate = "header" >
< span [style]="{'color':'green'}">
Hi Geek !
< i class = "pi pi-sun pi-spin" ></ i >
</ span ></ ng-template >
< 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 >
|
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:
Fieldset Custom Legend
Example 2: We are creating a UI that shows Angular PrimeNG Fieldset Custom Legend.
HTML
< div style = "margin:100px;" >
< h1 style = "color: green;" >GeeksforGeeks</ h1 >
< h3 >Angular PrimeNG Fieldset Custom Legend</ h3 >
< br />
< p-fieldset >
< ng-template pTemplate = "header" >
< span style="color:green;
border: 2px green dotted;
padding:5px">
< i class = "pi pi-star pi-spin" ></ i >
DSA - Self Paced Course
< i class = "pi pi-star pi-spin" ></ i >
</ span >
</ ng-template >
< 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 >
</ div >
|
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:
Fieldset Custom Legend
Reference: https://primefaces.org/primeng/fieldset
Share your thoughts in the comments
Please Login to comment...