Open In App

Angular PrimeNG ScrollPanel Component

Last Updated : 15 Feb, 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 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:

  • style: It is the inline style of the component. It is of string data type & the default value is null.
  • styleClass: It is the style class of the component. It is of string data type & the default value is null.

Angular PrimeNG ScrollPanel Component Styling:

  • p-scrollpanel: It is the container element.
  • p-scrollpanel-wrapper: It is the wrapper of the content section.
  • p-scrollpanel-content: It is the content section.
  • p-scrollpanel-bar: It is the scrollbar handle.
  • p-scrollpanel-bar-x: It is for the handling of a horizontal bar scrollbar.
  • p-scrollpanel-bar-y: It is for the handling of a vertical bar scrollbar.

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.

  • app.component.html:

HTML




<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>


  • app.component.ts:

Javascript




import { Component, OnInit, ViewEncapsulation} 
    from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss']
})
  
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: Below is another example that illustrates the use of the Angular PrimeNG ScrollPanel Component using both vertical and horizontal scrolling.

  • app.component.html:

HTML




<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>


  • app.component.ts:

Javascript




import { Component, OnInit, ViewEncapsulation} 
    from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss']
})
  
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