Pagination

Pagination with page navigation, next and previous links.

Installation

npx nx g @spartan-ng/cli:ui pagination

Usage

import {
	HlmPaginationContent
	HlmPagination
	HlmPaginationEllipsis
	HlmPaginationItem
	HlmPaginationLink
	HlmPaginationNext
	HlmPaginationPrevious
} 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>

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]

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]

HlmPaginationContent

Selector: [hlmPaginationContent]

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmPaginationEllipsis

Selector: hlm-pagination-ellipsis

Inputs

PropTypeDefaultDescription
class ClassValue --
srOnlyText string More pages Screen reader only text for the ellipsis

HlmPaginationItem

Selector: [hlmPaginationItem]

Inputs

PropTypeDefaultDescription
class ClassValue --

Selector: [hlmPaginationLink]

Inputs

PropTypeDefaultDescription
class ClassValue --
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 Go to next page The aria-label for the next page link.
text string Next 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 Go to previous page The aria-label for the previous page link.
text string Previous The text to display for the previous page link.
iconOnly boolean false Whether the button should only display the icon.

HlmPagination

Selector: [hlmPagination]

Inputs

PropTypeDefaultDescription
class ClassValue --
aria-label string pagination The aria-label for the pagination component.

Examples

Query Params

Icon Only (Previous/Next)

Advanced Pagination

100 total items | 7 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 | 7 pages
Popover Menubar