Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Angular PrimeNG Tag Severities

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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

A Tag component is used to make a tag in order to categorize the content. Tag Severities have different color options i.e., success info, warning, and danger, which signifies the different severity levels.

Angular PrimeNG Tag Severities Properties:

  • value: It specifies the value to display inside the tag. It is of string data type, the default value is null.
  • severity: It specifies the severity type of the tag. It is of string data type, the default value is null.
  • styleClass: It defines the style class of the component. It is of string data type, the default value is null.

Syntax:

<p-tag styleClass="..."
    severity="..." 
    value="...">
</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:

 

  • Run the below command:
ng serve --open

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

app.component.html




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


app.component.ts




import { Component } from "@angular/core";
  
@Component({
  selector: "app-root",
  templateUrl: "./app.component.html",
  styleUrls: ["./app.component.scss"],
})
export class AppComponent {}


app.module.ts




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 Severity using info, warning, and danger severity.

app.component.html




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


app.component.ts




import { Component } from "@angular/core";
  
@Component({
  selector: "app-root",
  templateUrl: "./app.component.html",
  styleUrls: ["./app.component.scss"],
})
export class AppComponent {}


app.module.ts




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


My Personal Notes arrow_drop_up
Last Updated : 19 Aug, 2022
Like Article
Save Article
Similar Reads
Related Tutorials