Open In App

Angular PrimeNG ScrollPanel Templates

Last Updated : 31 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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 Angular PrimeNG ScrollPanel Templates.

The ScrollPanel Component is a lightweight, cross-browser replacement to the built-in browser scrollbar.

Angular PrimeNG ScrollPanel Templates: The templates are used to put some content on some pre-structured containers. ScrollPanel templates are discussed below:

  • content: This template is used to create content for the ScrollPanel

 

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: In this example, we will see vertical scrolling of the Scroll Panel in Angular PrimeNG.

  • app.component.html:

HTML




<h1 style="color:green">
    GeeksforGeeks
</h1>
<h2>
    Angular PrimeNG ScrollPanel Templates
</h2>
  
<p-scrollPanel [style]="{ height: '100px' }" pTemplate="content">
    <p>
        GeeksforGeeks is a Computer Science Portal.
        GeeksforGeeks is a Computer Science Portal.
        GeeksforGeeks is a Computer Science Portal.
        GeeksforGeeks is a Computer Science Portal.
        GeeksforGeeks is a Computer Science Portal.
    </p>
    <p>
        GeeksforGeeks is a Computer Science Portal.
        GeeksforGeeks is a Computer Science Portal.
        GeeksforGeeks is a Computer Science Portal.
        GeeksforGeeks is a Computer Science Portal.
        GeeksforGeeks is a Computer Science Portal.
    </p>
    <p>
        GeeksforGeeks is a Computer Science Portal.
        GeeksforGeeks is a Computer Science Portal.
        GeeksforGeeks is a Computer Science Portal.
        GeeksforGeeks is a Computer Science Portal.
        GeeksforGeeks is a Computer Science Portal.
    </p>
</p-scrollPanel>


  • app.component.ts:

Javascript




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


  • app.module.ts:

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 { ScrollPanelModule } from 'primeng/scrollpanel';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        ScrollPanelModule
    ],
    declarations: [ AppComponent ],
    bootstrap: [ AppComponent ]
})
  
export class AppModule { }


Output:

 

Example 2: In this example, we will see styling the content of the Scroll Panel in Angular PrimeNG.

  • app.component.html:

HTML




<div style="width: 60%;">
    <h1 style="color:green">
         GeeksforGeeks
    </h1>
    <h2>
         Angular PrimeNG ScrollPanel Templates
    </h2>
  
    <p-scrollPanel [style]="{ height: '100px' }" pTemplate="content">
        <p style="color:'blue'">
             GeeksforGeeks is a Computer Science Portal.
             GeeksforGeeks is a Computer Science Portal.
             GeeksforGeeks is a Computer Science Portal.
             GeeksforGeeks is a Computer Science Portal.
             GeeksforGeeks is a Computer Science Portal.
        </p>
         <p style="color:'red'">
             GeeksforGeeks is a Computer Science Portal.
             GeeksforGeeks is a Computer Science Portal.
             GeeksforGeeks is a Computer Science Portal.
             GeeksforGeeks is a Computer Science Portal.
             GeeksforGeeks is a Computer Science Portal.
        </p>
         <p style="color:'green'">
             GeeksforGeeks is a Computer Science Portal.
             GeeksforGeeks is a Computer Science Portal.
             GeeksforGeeks is a Computer Science Portal.
             GeeksforGeeks is a Computer Science Portal.
             GeeksforGeeks is a Computer Science Portal.
        </p>
    </p-scrollPanel>
</div>


  • app.component.ts:

Javascript




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


  • app.module.ts:

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 { ScrollPanelModule } from 'primeng/scrollpanel';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        ScrollPanelModule
    ],
    declarations: [ AppComponent ],
    bootstrap: [ AppComponent ]
})
  
export class AppModule { }


Output:

 

Reference: https://primefaces.org/primeng/scrollpanel



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads