Open In App

Angular PrimeNG Tag Pills

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 Tag Pills in Angular PrimeNG.

A tag component is used to make a tag in order to categorize the content. Tag Pills are used to add rounded corners around the tags when the [rounded] value is set to true.



Angular PrimeNG Tag Pills Properties:

Syntax:



<p-tag 
    styleClass="...."
    severity="...." 
    value="...."
    [rounded]="true">
</p-tag>

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: After complete installation, it will look like the following:

Project Structure

Run the below command to see the output:

ng serve --open

Example 1: Below is the example that illustrates the use of Angular PrimeNG Tag Pills using primary and success pills.




<h2 style="color: green">GeeksforGeeks</h2>
<h5>Angular PrimeNG Tag Pills</h5>
<p-tag styleClass="p-mr-2" 
       value="Geek-primary" 
       [rounded]="true"> 
</p-tag>
<p-tag severity="success" 
       value="Geek-success" 
       [rounded]="true"> 
</p-tag>




import { Component } from "@angular/core";
  
@Component({
  selector: "app-root",
  templateUrl: "./app.component.html",
  styleUrls: ["./app.component.scss"],
})
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 { TagModule } from "primeng/tag";
  
@NgModule({
  imports: [BrowserModule, 
              BrowserAnimationsModule, 
              TagModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}

Output:

 

Example 2: Below is another example that illustrates the use of Angular PrimeNG Tag Pills using info, warning, and danger Pills.




<h2 style="color: green">GeeksforGeeks</h2>
<h5>Angular PrimeNG Tag Pills</h5>
<p-tag styleClass="p-mr-2" 
       severity="info" 
       value="Geek-info" 
       [rounded]="true">
</p-tag>
<p-tag styleClass="p-mr-2" 
       severity="warning" 
       value="Geek-warning" 
       [rounded]="true"> 
</p-tag>
<p-tag severity="danger" 
       value="Geek-danger" 
       [rounded]="true"> 
</p-tag>




import { Component } from "@angular/core";
  
@Component({
  selector: "app-root",
  templateUrl: "./app.component.html",
  styleUrls: ["./app.component.scss"],
})
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 { TagModule } from "primeng/tag";
  
@NgModule({
  imports: [BrowserModule, 
              BrowserAnimationsModule, 
              TagModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}

Output:

 

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


Article Tags :