Skip to content
Alpha

Hololink UI is under active development. Components, APIs and these docs may change without notice.

Holo Pagination

<holo-pagination> renders a nav landmark labelled “Pagination” with Previous/Next controls and a truncated list of page number buttons (collapsed with an ellipsis for large page counts). The current page is marked with aria-current="page", and the Previous/Next controls are disabled at the bounds.

Use it for:

  • Moving between pages of a long, ordered set of results where the user knows the page count.
  • Search results, tables and article lists split over several pages.

Don’t use it for:

  • Showing the user’s position in a site hierarchy. Use Breadcrumb.
  • Moving through the steps of a form. Show step state in your own wizard UI.
  • Infinite lists loaded on scroll. Provide a “Load more” Button.
<holo-pagination page="1" total-pages="5"></holo-pagination>
<holo-pagination page="10" total-pages="20" sibling-count="1"></holo-pagination>

The component renders a <nav> named by label (default “Pagination”) containing a <ul>. Every control is a native <button type="button">. Page buttons are named from pageLabel (default Page {page}, where {page} is replaced with the number) and the current one has aria-current="page". The previous and next buttons are named by previousLabel and nextLabel (default “Previous page” and “Next page”). At the first or last page they are natively disabled (and set aria-disabled="true"). Ellipses are aria-hidden.

Key Action
Tab Moves between the previous, page and next buttons
Enter, Space Goes to the focused page
  • There is no roving tabindex. Each button is a tab stop.
  • The focus ring is shown with :focus-visible.
  • The component emits holoPageChange but does not move focus or announce the new page. That is your job.

You provide:

  • A change that is perceivable after navigation: update the heading or a live region, or move focus to the start of the new content.
  • A distinct label if there are several pagination controls on one page, and translated label, previous-label, next-label and page-label for other languages.

Importing

import '@philbob-sideprojects/hololink-ui/holo-pagination';

Properties

PropertyAttributeTypeDefaultDescription
labellabelstring'Pagination'The accessible name of the navigation landmark. Give each pagination on a page a distinct label.
nextLabelnext-labelstring'Next page'The accessible name of the next-page button.
pagepagenumber1The current page (1-indexed). Updated when the user navigates.
pageLabelpage-labelstring'Page {page}'The accessible name of each page button. {page} is replaced with the page number.
previousLabelprevious-labelstring'Previous page'The accessible name of the previous-page button.
siblingCountsibling-countnumber1How many page numbers to show on either side of the current page.
totalPagestotal-pagesnumber1The total number of pages.

Events

EventDetailDescription
holoPageChangenumberEmitted when the user navigates to a different page. detail is the new page number.

CSS custom properties

PropertyDescription
--holo-pagination-current-bgBackground color of the current page button.
--holo-pagination-current-text-colorText color of the current page button.
--holo-pagination-gapSpace between pagination buttons.
--holo-pagination-text-colorText color of page buttons.