Open In App

Angular PrimeNG ScrollPanel Styling

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

The ScrollPanel Component is a lightweight, cross-browser replacement to the built-in browser scrollbar. This article will show ScrollPanel Styling in Angular PrimeNG. The ScrollPanel styling allows us to customize the default styling of the ScrollPanel using the classes so that we can create a custom design. ScrollPanel styling is discussed below:

Angular PrimeNG ScrollPanel 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 Styling using only vertical scrolling.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG ScrollPanel Styling</h5>
  
<p-scrollPanel>
    <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 { }


  • app.component.scss:

CSS




:host ::ng-deep .p-scrollpanel {
    padding: 1.5rem;
    line-height: 2;
    border: 5px solid green !important;
    box-shadow: 5px 10px #eb5454;
    height: 250px !important;
}


Output:

 

Example 2: Below is the example that illustrates the use of the Angular PrimeNG ScrollPanel Styling using horizontal scrolling.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG ScrollPanel Styling</h5>
  
<p-scrollPanel>
    <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,
    </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 { }


  • app.component.scss:

CSS




:host ::ng-deep .p-scrollpanel {
    p {
        padding: 1.5rem;
        line-height: 2;
        border: 5px solid green !important;
        box-shadow: 5px 10px #eb5454;
        width: 1000px;
    }
}


Output:

 

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



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads