Open In App

Angular PrimeNG Paginator Styling

Last Updated : 11 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. In this article, we will learn about Angular PrimeNG Paginator Styling.

The Paginator Component is used to display content in paged format. There are various styling classes available that help to enhance the user experience along with making it interactive.

Angular PrimeNG Paginator Styling:

  • p-paginator: It is the Container element.
  • p-paginator-first: It is the first-page element.
  • p-paginator-prev: It is the previous page element.
  • p-paginator-pages: It is the container of page links.
  • p-paginator-page: It is the page link.
  • p-paginator-next: It is the next page element.
  • p-paginator-last: It is the last page element.
  • p-paginator-rpp-options: It is the rows per page dropdown.
  • p-paginator-page-options: It is the jump to per page dropdown.

 

Syntax:

<p-paginator>...</p-paginator>

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:

 

Example 1: In this example, we will learn about p-paginator in Angular PrimeNG Paginator Styling

  • app.component.html

HTML




<h1 style="color:green">
  GeeksforGeeks
</h1>
<h2>
      PrimeNG Paginator Styling
</h2>
<p-paginator [rows]="1" 
             [totalRecords]="15">
</p-paginator>


  • 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 { FormsModule } from "@angular/forms";
import { BrowserAnimationsModule }
    from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { PaginatorModule } from "primeng/paginator";
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        PaginatorModule,
        FormsModule,
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent],
})
export class AppModule { }


Output:

 

Example 2: This is another example that describes the usage of the Angular PrimeNG Paginator Styling.

  • app.component.html

HTML




<div style="width:50%;">
    <h1 style="color:green">
        GeeksforGeeks
    </h1>
    <h2>
        Angular PrimeNG Paginator Styling 
    </h2>
    <p-paginator [rows]="5" 
                 [totalRecords]="10" 
                 [showCurrentPageReport]="true" 
                 [alwaysShow]="true" 
                 [showFirstLastIcon]="true" 
                 [showJumpToPageDropdown]="true">
    </p-paginator>
</div>


  • app.component.ts

Javascript




import { Component } from '@angular/core';
import { PrimeNGConfig } from 'primeng/api';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
})
export class AppComponent {
    constructor(private primengConfig: PrimeNGConfig) { }
  
    ngOnInit() {
        this.primengConfig.ripple = true;
    }
}


  • app.module.ts

Javascript




import { NgModule } from '@angular/core';
import { BrowserModule } 
    from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from
    '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { PaginatorModule } from 'primeng/paginator';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        PaginatorModule,
        FormsModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }


Output:

 

Reference: http://primefaces.org/primeng/paginator



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads