Angular PrimeNG DataView Styling
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. In this article, we will know how to use the DataView Styling in Angular PrimeNG.
The DataView Component is used to display data in a grid and list layout with pagination and sorting features. The Styling classes are used to add some CSS styles on DataView components.
Angular PrimeNG DataView Styling:
- p-dataview: It is a styling Container element.
- p-dataview-list: It is a styling Container element in the list layout.
- p-dataview-grid: It is a styling Container element in the grid layout.
- p-dataview-header: It is a styling Header section.
- p-dataview-footer: It is a styling Footer section.
- p-dataview-content: It is a styling Container of items.
- p-dataview-emptymessage: It is a styling Empty message element.
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: To run the above file run the below command:
ng serve --save
Example 1: This is the basic example that shows how to use the DataView Styling.
HTML
<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG DataView Styling</h5>
<div class="card">
<p-dataView
#dv [value]="gfg" [paginator]="true"
[rows]="4" filterBy="name" layout="grid">
<ng-template pTemplate="header">
<p-dataViewLayoutOptions>
</p-dataViewLayoutOptions>
</ng-template>
<ng-template let-product pTemplate="gridItem">
<div class="p-col-12 p-md-4">
<div class="product-grid-item">
<button pButton pRipple type="button"
label="GeeksforGeeks"
class="p-button-success">
</button>
</div>
</div>
</ng-template>
</p-dataView>
</div>
JavaScript
import { Component } from "@angular/core";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.scss"],
})
export class AppComponent {
gfg: string[] = [
"gfg1",
"gfg2",
"gfg3",
"gfg4",
"gfg5",
"gfg6",
"gfg7",
"gfg8",
"gfg9",
"gfg10"
];
ngOnInit() {}
}
JavaScript
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { HttpClientModule } from "@angular/common/http";
import { BrowserAnimationsModule }
from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { DataViewModule } from "primeng/dataview";
import {ButtonModule} from 'primeng/button';
@NgModule({
imports: [
ButtonModule,
BrowserModule,
BrowserAnimationsModule,
DataViewModule,
HttpClientModule,
FormsModule,
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule {}
CSS
:host ::ng-deep .product-grid-item {
margin: .9em;
border: 5px solid #2fcc7d;
}
Output:
Example 2: This is another basic example that shows how to use the DataView Styling.
HTML
<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG DataView Styling</h5>
<div class="card">
<p-dataView
#dv [value]="gfg" [paginator]="true"
[rows]="4" filterBy="name" layout="grid">
<ng-template let-product pTemplate="gridItem">
<div class="p-col-12 p-md-4">
<div class="product-grid-item">
<button pButton pRipple type="button"
label="GeeksforGeeks"
class="p-button-success">
</button>
</div>
</div>
</ng-template>
</p-dataView>
</div>
JavaScript
import { Component } from "@angular/core";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.scss"],
})
export class AppComponent {
gfg: string[] = [
"gfg1",
"gfg2",
"gfg3",
"gfg4",
"gfg5",
"gfg6",
"gfg7",
"gfg8",
"gfg9",
"gfg10"
];
ngOnInit() {}
}
JavaScript
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { HttpClientModule } from "@angular/common/http";
import { BrowserAnimationsModule }
from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { DataViewModule } from "primeng/dataview";
import {ButtonModule} from 'primeng/button';
@NgModule({
imports: [
ButtonModule,
BrowserModule,
BrowserAnimationsModule,
DataViewModule,
HttpClientModule,
FormsModule,
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule {}
CSS
:host ::ng-deep .product-grid-item {
margin: .1em;
}
.card {
padding: 2rem;
box-shadow: 0 20px 20px -2px rgba(241, 2, 14, 0.966),
0 1px 1px 0 rgba(241, 9, 28, 0.925),
0 1px 3px 0 rgba(192, 4, 4, 0.932);
border-radius: 10px;
margin-bottom: 2rem;
}
Output:
Reference: https://primefaces.org/primeng/dataview
Similar Reads
Angular PrimeNG Panel Styling A responsive website may be easily created using the open-source Angular PrimeNG framework, which has a wide range of native Angular UI components for superb style. This article will learn how to style Panel Styling in Angular PrimeNG. The Panel Component enables us to create an element with a head
4 min read
Angular PrimeNG Image Styling 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.
3 min read
Angular PrimeNG Inplace Styling 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 see Angular PrimeNG Inplace Styling. The Inplace component is used to provide an easy to do
3 min read
Angular PrimeNG DataView 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 DataView Templates in Angular PrimeNG. Â The DataView C
3 min read
Angular PrimeNG Fieldset Styling 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 Fieldset Styling in Angular PrimeNG. Fieldset Component is a grouping comp
3 min read
Angular PrimeNG OrderList Styling 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 the Angular PrimeNG OrderList Styling. The OrderList Component is used
2 min read
Angular PrimeNG Tree Styling 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.
5 min read
Angular PrimeNG DataView 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 about Angular PrimeNG DataView Events. The DataView Component is used
3 min read
Angular PrimeNG Skeleton DataTable Angular PrimeNG is an open-source front-end UI library that has many native Angular UI components which help developers to build a fast and scalable web solution. In this article, we will be seeing Angular PrimeNG Skeleton DataTable. The Skeleton Component is used as a placeholder while the data for
4 min read
Angular PrimeNG Table Styling 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 Table Styling in Angular PrimeNG. The Table component shows som
4 min read