Angular PrimeNG Avatar Badge
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. Avatars are used to denote letters, icons, and images in different shapes and background colors.
This article will show us how to use the different Avatar badges in Angular PrimeNG. Badges can be applied to the image or icon or letter content of Avatar respectively.
Approach: Let us create an Angular project and install the PrimeNG UI module. Then we will create a UI that will showcase Angular PrimeNG Avatar Badge.
Step 1: To create an angular app, you need to install angular by command line interface through 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 Label Avatar Badges.
app.component.html
< div style = "margin:100px" >
< h2 style = "color: green;" >GeeksforGeeks</ h2 >
< h3 >Angular PrimeNG Label Avatar Badges </ h3 >
< div class = "d-flex ai-center" style = "margin:20px" >
< p-avatar label = "G" size = "xlarge"
pBadge value = "30" severity = "warning"
[style]="{'background-color':'green',
'color': 'white', 'margin':'20px'}">
</ p-avatar >
< p-avatar label = "F" size = "xlarge"
pBadge severity = "info" >
</ p-avatar >
< p-avatar label = "G" size = "xlarge"
pBadge value = "50" severity = "danger"
[style]="{'background-color':'green',
'color': 'white','margin':'20px'}">
</ p-avatar >
</ div >
</ div >
|
app.module.ts
import { NgModule } from '@angular/core' ;
import { BrowserModule } from '@angular/platform-browser' ;
import { AvatarModule } from 'primeng/avatar' ;
import { AppComponent } from './app.component' ;
import { BadgeModule } from 'primeng/badge' ;
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AvatarModule,
BadgeModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
|
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
Example 2: We are creating a UI that shows Angular PrimeNG Icon Avatar Badges.
app.component.html
< div style = "margin:100px" >
< h2 style = "color: green" >GeeksforGeeks</ h2 >
< h3 >Angular PrimeNG Icon Avatar Badges </ h3 >
< div class = "d-flex ai-center" style = "margin:20px" >
< p-avatar icon = "pi pi-user" size = "xlarge"
pBadge value = "10" severity = "info"
[style]="{'background-color':'green',
'color': 'white', 'margin':'20px'}">
</ p-avatar >
< p-avatar icon = "pi pi-prime" size = "xlarge"
pBadge severity = "danger" >
</ p-avatar >
< p-avatar icon = "pi pi-search" size = "xlarge"
pBadge value = "20" severity = "warning"
[style]="{'background-color':'black',
'color': 'white','margin':'20px'}">
</ p-avatar >
</ div >
</ div >
|
app.module.ts
import { NgModule } from '@angular/core' ;
import { BrowserModule } from '@angular/platform-browser' ;
import { AvatarModule } from 'primeng/avatar' ;
import { AppComponent } from './app.component' ;
import { BadgeModule } from 'primeng/badge' ;
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AvatarModule,
BadgeModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
|
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
Reference: https://primefaces.org/primeng/avatar
Similar Reads
Angular PrimeNG Avatar Image
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 Avatar Image in Angular PrimeNG. Letâs learn about the prop
3 min read
Angular PrimeNG Avatar Label
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 Avatar Label in Angular PrimeNG. Letâs learn about the prop
3 min read
Angular PrimeNG Avatar Icon
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 Avatar Icon in Angular PrimeNG. Letâs learn about the prope
3 min read
Angular PrimeNG AvatarGroup
Angular PrimeNG is a UI component library for Angular Applications. It offers many pre-built themes and UI components for a variety of tasks like inputs, menus, charts, Buttons, etc. In this article, we will be seeing Angular PrimeNG AvatarGroup. The AvatarGroup Component is used to group avatars to
2 min read
Angular PrimeNG Avatar Component
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 know how to use the Avatar component in Angular PrimeNG. Letâs learn about
4 min read
Angular PrimeNG Avatar Shape
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. Avatars are used to denote letters, icons, and images in different shapes and background colors. Thi
3 min read
Angular PrimeNG Avatar Sizes
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. Avatars are used to denote letters, icons, and images in different shapes and background colors. Thi
3 min read
Angular PrimeNG Image Events
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 know how to use Angular PrimeNG Image Events. The Image Component is used t
3 min read
Angular PrimeNG Inplace Data
Angular PrimeNG is a UI component library for Angular Applications. It offers many pre-built themes and UI components for a variety of tasks like inputs, menus, charts, Buttons, etc. In this article, we will be seeing Angular PrimeNG Inplace Data. The Inplace component is used to provide an easy to
3 min read
Angular PrimeNG Badge Sizes
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 Badge Sizes in Angular PrimeNG. The Badge component represe
3 min read