Pagination

Pagination with page navigation, next and previous links.

Installation

ng g @spartan-ng/cli:ui pagination

Usage

import { HlmPaginationImports } from '@spartan-ng/helm/pagination';
<nav hlmPagination>
  <ul hlmPaginationContent>
    <li hlmPaginationItem>
      <hlm-pagination-previous link="/components/menubar" />
    </li>
    <li hlmPaginationItem>
      <a hlmPaginationLink link="#">1</a>
    </li>
    <li hlmPaginationItem>
      <a hlmPaginationLink link="#" isActive>2</a>
    </li>
    <li hlmPaginationItem>
      <a hlmPaginationLink link="#">3</a>
    </li>
    <li hlmPaginationItem>
      <hlm-pagination-ellipsis />
    </li>
    <li hlmPaginationItem>
      <hlm-pagination-next link="/components/popover" />
    </li>
  </ul>
</nav>

Examples

Query Params

Icon Only (Previous/Next)

Advanced Pagination

100 total items | 10 pages

Advanced Pagination - Query Params

Use hlm-numbered-pagination-query-params instead of hlm-numbered-pagination to synchronize pagination state with query params.

100 total items | 10 pages

RTL

To enable RTL support in spartan-ng, see the RTL configuration guide.

Helm API

HlmNumberedPaginationQueryParams

Selector: hlm-numbered-pagination-query-params

Inputs

PropTypeDefaultDescription
totalItems* (required) number - The total number of items in the collection. Only useful when doing server-side paging, where the collection size is limited to a single page returned by the server API.
link string '.' The URL path to use for the pagination links. Defaults to '.' (current path).
maxSize number 7 The number of page links to show.
showEdges boolean true Show the first and last page buttons.
pageSizes number[] [10, 20, 50, 100] The page sizes to show. Defaults to [10, 20, 50, 100]
totalItemsLabel string this._config.totalItemsLabel The label for total items or pages to show Defaults to config's totalItemsLabel
pagesLabel string this._config.pagesLabel The label for pages to show Defaults to config's pagesLabel
nextLabel string this._config.nextLabel The label to show on the next button Defaults to config's nextLabel
nextAriaLabel string this._config.nextAriaLabel The aria-label to show on the next button Defaults to config's nextAriaLabel
previousLabel string this._config.previousLabel The label to show on the previous button Defaults to config's previousLabel
previousAriaLabel string this._config.previousAriaLabel The aria-label to show on the previous button Defaults to config's previousAriaLabel
currentPage* (required) number - The current (active) page.
itemsPerPage* (required) number - The number of items per paginated page.

Outputs

PropTypeDefaultDescription
currentPageChange* (required) number - The current (active) page.
itemsPerPageChange* (required) number - The number of items per paginated page.

HlmNumberedPagination

Selector: hlm-numbered-pagination

Inputs

PropTypeDefaultDescription
totalItems* (required) number - The total number of items in the collection. Only useful when doing server-side paging, where the collection size is limited to a single page returned by the server API.
maxSize number 7 The number of page links to show.
showEdges boolean true Show the first and last page buttons.
pageSizes number[] [10, 20, 50, 100] The page sizes to show. Defaults to [10, 20, 50, 100]
totalItemsLabel string this._config.totalItemsLabel The label for total items or pages to show Defaults to config's totalItemsLabel
pagesLabel string this._config.pagesLabel The label for pages to show Defaults to config's pagesLabel
nextLabel string this._config.nextLabel The label to show on the next button Defaults to config's nextLabel
nextAriaLabel string this._config.nextAriaLabel The aria-label to show on the next button Defaults to config's nextAriaLabel
previousLabel string this._config.previousLabel The label to show on the previous button Defaults to config's previousLabel
previousAriaLabel string this._config.previousAriaLabel The aria-label to show on the previous button Defaults to config's previousAriaLabel
currentPage* (required) number - The current (active) page.
itemsPerPage* (required) number - The number of items per paginated page.

Outputs

PropTypeDefaultDescription
currentPageChange* (required) number - The current (active) page.
itemsPerPageChange* (required) number - The number of items per paginated page.

HlmPaginationContent

Selector: ul[hlmPaginationContent]

HlmPaginationEllipsis

Selector: hlm-pagination-ellipsis

Inputs

PropTypeDefaultDescription
srOnlyText string 'More pages' Screen reader only text for the ellipsis

HlmPaginationItem

Selector: li[hlmPaginationItem]

Selector: [hlmPaginationLink]

Inputs

PropTypeDefaultDescription
isActive boolean false Whether the link is active (i.e., the current page).
size ButtonVariants['size'] 'icon' The size of the button.
link RouterLink['routerLink'] - The link to navigate to the page.

HlmPaginationNext

Selector: hlm-pagination-next

Inputs

PropTypeDefaultDescription
class ClassValue '' -
link RouterLink['routerLink'] - The link to navigate to the next page.
queryParams RouterLink['queryParams'] - The query parameters to pass to the next page.
queryParamsHandling RouterLink['queryParamsHandling'] - How to handle query parameters when navigating to the next page.
aria-label string this._config.nextAriaLabel The aria-label for the next page link.
text string this._config.nextLabel The text to display for the next page link.
iconOnly boolean false Whether the button should only display the icon.

HlmPaginationPrevious

Selector: hlm-pagination-previous

Inputs

PropTypeDefaultDescription
class ClassValue '' -
link RouterLink['routerLink'] - The link to navigate to the previous page.
queryParams RouterLink['queryParams'] - The query parameters to pass to the previous page.
queryParamsHandling RouterLink['queryParamsHandling'] - How to handle query parameters when navigating to the previous page.
aria-label string this._config.previousAriaLabel The aria-label for the previous page link.
text string this._config.previousLabel The text to display for the previous page link.
iconOnly boolean false Whether the button should only display the icon.

HlmPagination

Selector: [hlmPagination],hlm-pagination

Inputs

PropTypeDefaultDescription
aria-label string 'pagination' The aria-label for the pagination component.
Popover Navigation Menu