Canopy Pagination — Best Practices

SkillDatabases & data

Best practices for the Canopy Pagination component. Trigger when paginating lists, controlling paged datasets, or adding page navigation controls in an Angular project using Canopy.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Canopy Pagination — Best Practices skill

What this skill tells your AI

The instructions your AI receives, as published by legal-and-general/canopy in skills/best-practice/pagination/SKILL.md and read by ahel’s review.

This skill provides usage guidance and input reference for the Canopy lg-pagination component from @legal-and-general/canopy.

Apply this skill whenever you use LgPaginationComponent or lg-pagination.


Import

import { LgPaginationComponent, PageData } from '@legal-and-general/canopy';

Basic Usage

Template:

<lg-pagination
  [totalItems]="allItems.length"
  [itemsPerPage]="itemsPerPage"
  [currentPage]="currentPage"
  (pageChanged)="onPageChanged($event)"
/>

Component:

import { PageData } from '@legal-and-general/canopy';

export class MyListComponent implements OnInit {
  allItems: Item[] = [];
  pagedItems: Item[] = [];
  itemsPerPage = 10;
  currentPage = 1;

  ngOnInit(): void {
    this.allItems = this.dataService.getData();
    this.pagedItems = this.getPagedData(0, this.itemsPerPage - 1);
  }

  onPageChanged(pageData: PageData): void {
    this.currentPage = pageData.pageNumber;
    this.pagedItems = this.getPagedData(pageData.startIndex, pageData.endIndex);
  }

  private getPagedData(startIndex: number, endIndex: number): Item[] {
    return this.allItems.slice(startIndex, endIndex + 1);
  }
}

Use Array.prototype.slice, not splice. slice(startIndex, endIndex + 1) returns items up to and including endIndex.

If you previously used pageData.page, update handlers to use pageData.pageNumber.


Inputs

InputTypeDefaultRequiredDescription
totalItemsnumber0NoTotal number of items in the dataset.
itemsPerPagenumber10NoNumber of items shown per page.
currentPagenumber1NoThe current page. Controlled internally but can be set programmatically.
idstringauto-generatedNoHTML id attribute.

Outputs

OutputTypeDescription
pageChangedEventEmitter<PageData>Emitted when the page changes. Use to update displayed data.

PageData interface

interface PageData {
  pageNumber: number; // Requested page number (1-based)
  startIndex: number; // Zero-based start index
  endIndex: number;   // Inclusive end index
}

Design Constraints

  • The component hides itself automatically when totalItems <= itemsPerPage (i.e. there is only one page).
  • Desktop and tablet controls show previous/next plus page buttons, capped to a maximum of 9 controls in total (including ellipses). The first page, last page, current page, and nearby neighbours are preserved.
  • Mobile controls use a sliding window of 3 page buttons with no ellipses.
  • The results label ("Showing x-y of n results") is rendered in an aria-live region, with the range and total emphasised using semantic <strong> text.

Signals

GitHub stars
23
Forks
46
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
canopy-pagination
Source
github.com/legal-and-general/canopy