Angular PrimeNG Card Templates
Last Updated :
28 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. This article will show us how to use the Card Templates in Angular PrimeNG.
The Card Component is used to display flexible and extensible content containers. This article will show the Card Templating in Angular PrimeNG. The templates are used to put some content on some pre-structured containers.
Card templates are discussed below:
- header: This is used to place the header of the Card component.
- title: This is used to place the title of the Card component.
- subtitle: This is used to place the subtitle of the Card component.
- content: This is used to place the content of the Card component.
- footer: This is used to place the footer of the Card component.
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: It will look like the following:
Steps to run the application: Run the below command to see the output
ng serve --save
Example 1: Below is the example code that illustrates the use of Angular PrimeNG Card Templates using "header" and "footer" pTemplates.
HTML
<h1 style="color:green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Card Templates</h5>
<p-card>
<ng-template pTemplate="header">
<img alt="Card" height="200" src=
"https://media.geeksforgeeks.org/img-practice/banner/cpp-stl-course-overview-image.png?v=1665307466" />
</ng-template>
<ng-template pTemplate="footer">
<Button pButton>Card Button</Button>
</ng-template>
</p-card>
JavaScript
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent { }
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 { ButtonModule } from 'primeng/button';
import { CardModule, } from 'primeng/card';
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
CardModule,
ButtonModule,
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
Output:
Example 2: Below is another example code that illustrates the use of Angular PrimeNG Card Templates using "header", "footer", "title", "subtitle", and "content" pTemplates.
HTML
<h1 style="color:green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Card Templates</h5>
<p-card>
<ng-template pTemplate="header">
<img alt="Card" height="200" src=
"https://media.geeksforgeeks.org/img-practice/banner/cpp-stl-course-overview-image.png?v=1665307466" />
</ng-template>
<ng-template pTemplate="title">
GeeksforGeeks Title
</ng-template>
<ng-template pTemplate="subtitle">
GeeksforGeeks Subtitle
</ng-template>
<ng-template pTemplate="content">
GeeksforGeeks Content: It is a Computer Science portal.
</ng-template>
<ng-template pTemplate="footer">
<Button pButton>Card Button</Button>
</ng-template>
</p-card>
JavaScript
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent { }
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 { ButtonModule } from 'primeng/button';
import { CardModule, } from 'primeng/card';
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
CardModule,
ButtonModule,
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
Output:
Reference: https://primefaces.org/primeng/card
Similar Reads
Angular PrimeNG Carousel Templates 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. It provides a lot of templates, components, theme design, an extensive icon library, and much more.
4 min read
Angular PrimeNG Image Templates Angular PrimeNG is an open-source library that consists 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 discuss Angular PrimeNG Image Templates. The Image Component is used to show an
3 min read
Angular PrimeNG Panel Templates 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 Panel Templates in Angular PrimeNG. The Panel Component all
4 min read
Angular PrimeNG Galleria Templates 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. It provides a lot of templates, components, theme design, an extensive icon library, and much more.
4 min read
Angular PrimeNG Dialog Templates 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 Dialog Templates in Angular PrimeNG. The Dialog Compone
3 min read