Angular PrimeNG VirtualScroller Styling
Last Updated :
24 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 see how to use Angular PrimeNG VirtualScroller Styling.
VirtualScroller is an efficient way of rendering lists by displaying a small subset of data in the viewport at any time.
Angular PrimeNG VirtualScroller Styling: This component helps to make the interactive Form VirtualScroller by implementing the different stylings provided by Angular PrimeNG.
These styling components are described below:
- p-virtualscroller: This is used for the Container element.
- p-virtualscroller-header: This is used for the Header section.
- p-virtualscroller-footer: This is used for the Footer section.
- p-virtualscroller-content: This is used for the Content section.
- p-virtualscroller-list : This is used for the list element.
Syntax:
<p-virtualScroller
[value]="..." scrollHeight="..." [itemSize]="...">
<ng-template pTemplate="item" let-item>
...
</ng-template>
</p-virtualScroller>
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:
Example 1: In this example, we will learn about p-virtualscroller.
HTML
< div style = "width:80%" >
< h1 style = "color: green;" >
GeeksforGeeks
</ h1 >
< h2 >
Angular PrimeNG VirtualScroller Styling
</ h2 >
< p-virtualScroller
[value]="items" scrollHeight = "250px" [itemSize]="20"
[lazy]="true" [delay]=250>
< ng-template pTemplate = "item" let-item>
{{item.label}}
</ ng-template >
</ p-virtualScroller >
</ div >
|
Javascript
import { Component } from "@angular/core" ;
import { MenuItem } from "primeng/api" ;
import { LazyLoadEvent,SelectItem } from 'primeng/api' ;
@Component({
selector: "app-root" ,
templateUrl: "./app.component.html"
})
export class AppComponent {
items: MenuItem[]=[];
ngOnInit() {
this .items = [
{
label: "Visit Website"
},
{
label: "Like"
},
{
label: "More"
},
{
label: "Subscribe"
},
{
label: "Quit"
},
{
label: "New"
},
{
label: "Share"
},
{
label: "Search"
},
{
label: "Visit Website"
},
{
label: "Like"
},
{
label: "More"
},
{
label: "Subscribe"
},
{
label: "Quit"
},
{
label: "New"
},
{
label: "Share"
},
{
label: "Search"
},
{
label: "Visit Website"
},
{
label: "Like"
},
{
label: "More"
},
{
label: "Subscribe"
},
{
label: "Quit"
},
{
label: "New"
},
{
label: "Share"
},
{
label: "Search"
},
{
label: "Visit Website"
},
{
label: "Like"
},
{
label: "More"
},
{
label: "Subscribe"
},
{
label: "Quit"
},
{
label: "New"
},
{
label: "Share"
},
{
label: "Search"
}
];
}
}
|
Javascript
import { NgModule } from "@angular/core" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { RouterModule } from "@angular/router" ;
import { BrowserAnimationsModule }
from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { ContextMenuModule } from "primeng/contextmenu" ;
import {VirtualScrollerModule} from 'primeng/virtualscroller' ;
import { TableModule } from 'primeng/table' ;
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
ContextMenuModule,
TableModule,
VirtualScrollerModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {}
|
Output:
Example 2: In this example, we will learn about p-virtualscroller-header and p-virtualscroller-footer.
HTML
< div style = "width:80%" >
< h1 style = "color: green;" >
GeeksforGeeks
</ h1 >
< h2 >
Angular PrimeNG VirtualScroller Styling
</ h2 >
< p-virtualScroller
[value]="items" scrollHeight = "250px" [itemSize]="20"
[lazy]="true" [delay]=250>
< ng-template pTemplate = "header" >
I am Header of VirtualScroller
</ ng-template >
< ng-template pTemplate = "item" let-item>
{{item.label}}
</ ng-template >
< ng-template pTemplate = "footer" >
I am Footer of VirtualScroller
</ ng-template >
</ p-virtualScroller >
</ div >
|
Javascript
import { Component } from "@angular/core" ;
import { MenuItem } from "primeng/api" ;
import { LazyLoadEvent,SelectItem } from 'primeng/api' ;
@Component({
selector: "app-root" ,
templateUrl: "./app.component.html"
})
export class AppComponent {
items: MenuItem[]=[];
ngOnInit() {
this .items = [
{
label: "Visit Website"
},
{
label: "Like"
},
{
label: "More"
},
{
label: "Subscribe"
},
{
label: "Quit"
},
{
label: "New"
},
{
label: "Share"
},
{
label: "Search"
},
{
label: "Visit Website"
},
{
label: "Like"
},
{
label: "More"
},
{
label: "Subscribe"
},
{
label: "Quit"
},
{
label: "New"
},
{
label: "Share"
},
{
label: "Search"
},
{
label: "Visit Website"
},
{
label: "Like"
},
{
label: "More"
},
{
label: "Subscribe"
},
{
label: "Quit"
},
{
label: "New"
},
{
label: "Share"
},
{
label: "Search"
},
{
label: "Visit Website"
},
{
label: "Like"
},
{
label: "More"
},
{
label: "Subscribe"
},
{
label: "Quit"
},
{
label: "New"
},
{
label: "Share"
},
{
label: "Search"
}
];
}
}
|
Javascript
import { NgModule } from "@angular/core" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { RouterModule } from "@angular/router" ;
import { BrowserAnimationsModule }
from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { ContextMenuModule } from "primeng/contextmenu" ;
import {VirtualScrollerModule} from 'primeng/virtualscroller' ;
import { TableModule } from 'primeng/table' ;
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
ContextMenuModule,
TableModule,
VirtualScrollerModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {}
|
Output:
Reference: http://primefaces.org/primeng/virtualscroller
Similar Reads
Angular PrimeNG Table VirtualScroll
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 Table VirtualScroll in Angular PrimeNG. Angular PrimeNG
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
Angular PrimeNG VirtualScroller 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 see how to use Angular PrimeNG VirtualScroller Events. VirtualScroller is a
4 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 Table VirtualScroller Properties
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 Properties. VirtualScroller: By displaying
7 min read
Angular PrimeNG Toolbar 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 learn how to use the Toolbar Styling in Angular PrimeNG. The Toolbar Compon
3 min read
Angular PrimeNG Tag 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 Angular PrimeNG Tag Properties. A tag component is used to create tags
3 min read
Angular PrimeNG TabMenu 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.
4 min read
Angular PrimeNG TabView 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 TabView Styling. The TabView Component is used to
3 min read
Angular PrimeNG Table VirtualScroller Lazy Loading
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 Angular PrimeNG VirtualScroller Lazy Loading. VirtualSc
6 min read