Open In App

Angular PrimeNG ScrollPanel 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 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:

 



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.




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




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




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




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




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




: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


Article Tags :