Open In App

Angular PrimeNG ScrollPanel 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. This article will show us how to use the ScrollPanel Component in Angular PrimeNG. We will also learn about the various properties and syntaxes used in the code example.

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



Import: In order to use the Galleria, we need to import the following statement in the module file:

import {ScrollPanelModule} from 'primeng/scrollpanel';

 



Syntax:

<p-scrollPanel [style]="{....}">
    <p>...</p>
</p-scrollPanel>

Angular PrimeNG ScrollPanel Component Properties:

Angular PrimeNG ScrollPanel Component Styling:

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: Below is the example that illustrates the use of the Angular PrimeNG ScrollPanel Component using only vertical scrolling.




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG ScrollPanel Component</h5>
  
<p-scrollPanel [style]="{ height: '300px' }">
    <p>
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
    </p>
</p-scrollPanel>




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




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: Below is another example that illustrates the use of the Angular PrimeNG ScrollPanel Component using both vertical and horizontal scrolling.




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG ScrollPanel Component</h5>
  
<p-scrollPanel [style]="{ height: '300px' }">
    <p style="width: 500px">
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
        GeeksforGeeks, 
        It is a Computer Science Portal for all the geeks.
    </p>
</p-scrollPanel>




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




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


Article Tags :