Angular PrimeNG Chip Templating
Last Updated :
26 Apr, 2025
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.
Chip component is used to represent icons, labels, and images. This article will show us the Chip Templating in Angular PrimeNG. We are altering the expected behavior by using the chip template where we can define custom content.
Approach: Let us create an Angular project and install the PrimeNG UI module. Then we will create a UI that will showcase Angular PrimeNG Chip Templating.
Syntax:
<p-chip>
...
</p-chip>
Creating Angular Application & module installation:
Step 1: To create an angular app, you must install angular by 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 react 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, if you open the project in an editor you can see a similar project structure as shown below. The new component user makes or the code changes, we will be performing will be done in the source folder.
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 Chip Templating. Here, we are creating nested chips (4 removable chips inside a chip).
HTML
<div style="text-align: center;">
<h1 style="color: green">GeeksforGeeks</h1>
<h3>Angular PrimeNG Chip Templating</h3>
<p>Chips inside a Chip</p>
<br />
<p-chip [style]=
"{backgroundColor:'green',width:'500px',height:'80px'}">
<p-chip
label="Chip 1"
icon="pi pi-hashtag"
[removable]="true"
styleClass="p-mr-1">
</p-chip>
<p-chip
label="Chip 2"
icon="pi pi-hashtag"
[removable]="true"
styleClass="p-mr-1">
</p-chip><br />
<p-chip
label="Chip 3"
icon="pi pi-hashtag"
[removable]="true"
styleClass="p-mr-1">
</p-chip><br />
<p-chip
label="Chip 4"
icon="pi pi-hashtag"
[removable]="true"
styleClass="p-mr-1">
</p-chip>
</p-chip>
</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 { ChipModule } from 'primeng/chip';
import { ProgressSpinnerModule } from 'primeng/progressspinner';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
ChipModule,
ProgressSpinnerModule,
BrowserAnimationsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Output:
Example 2: We are creating a UI that shows Angular PrimeNG Chip Templating. Here, we are inserting a progress spinner component inside the chip.
HTML
<div style="margin:100px; text-align: center;">
<h1 style="color: green">
GeeksforGeeks
</h1>
<h3>
Angular PrimeNG Chip Templating
</h3>
<br />
<p-chip>
<p-progressSpinner
strokeWidth="1"
fill="yellow">
</p-progressSpinner>
</p-chip>
</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 { ChipModule } from 'primeng/chip';
import { ProgressSpinnerModule } from 'primeng/progressspinner';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
ChipModule,
ProgressSpinnerModule,
BrowserAnimationsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Output:
Reference: https://primefaces.org/primeng/chip