Pagination
The <nys-pagination> component provides Previous/Next buttons and numbered page links for navigating large sets of content or data. It auto-collapses page numbers with ellipses when there are many pages, and renders a compact layout on mobile.
<nys-pagination currentPage="2" totalPages="7"></nys-pagination>
Can't use NYS Design System web components in your project? Try using the CSS Variables instead.
Accessibility
The <nys-pagination> component includes the following accessibility-focused features:
-
Each page button includes an
ariaLabelof "Page N" so screen readers announce the page number clearly. -
Previous and Next buttons are disabled (not removed) when at the first or last page, so screen readers can still discover them and understand the navigation range.
-
On mobile, Previous and Next buttons switch to icon-only versions with
ariaLabelattributes ("Previous Page" / "Next Page") to maintain accessibility without visible labels. -
All buttons are keyboard-focusable. Users can
Tabthrough pagination controls and activate them withEnterorSpace. -
The component auto-collapses page numbers with ellipsis buttons to reduce cognitive load, especially on smaller screens.
Additional accessibility test and build content is coming soon, in a new format.
Options
First Page
When currentPage is 1, the Previous button is disabled. The component shows the first few page numbers and the last page.
<nys-pagination currentPage="1" totalPages="12"></nys-pagination>
Middle Page
When the user is in the middle of the result set, the component shows ellipsis on both sides with the current page centered.
<nys-pagination currentPage="6" totalPages="12"></nys-pagination>
Last Page
When currentPage equals totalPages, the Next button is disabled. The component shows the first page and the last few page numbers.
<nys-pagination currentPage="12" totalPages="12"></nys-pagination>
Few Pages
When there are only a handful of pages, all page numbers are shown without ellipsis.
<nys-pagination currentPage="2" totalPages="3"></nys-pagination>
Single Page
When totalPages is 1, the component renders nothing. Pagination is unnecessary when all content fits on one page.
Responsive Behavior
On screens below 768px, the component automatically switches to a condensed layout: Previous and Next buttons become icon-only, and neighboring page numbers are hidden to save space.
Usage
Do
- Use for large result sets such as search results, data tables, or directory listings where loading everything at once would hurt performance or usability.
- Use when users need to navigate to a specific part of a result set.
- Set
totalPagesbased on your data set and page size; updatecurrentPagein response tonys-changeevents. - Don't set
currentPageto a value greater thantotalPages. The component clamps the value automatically, but your application logic should prevent this. - Position the pagination component below the content it controls.
- Scroll users to the top of the results area when they change pages.
Don't
- Use when content fits on a single page (fewer than 3–4 screen heights). Show all items instead.
- Use for step-based workflows where users complete tasks in order. Use
<nys-stepper>instead. - Use for infinite-scroll patterns such as a news feed.
Properties
| Property | Type | Default |
|---|---|---|
id |
String | "" |
name |
String | "" |
currentPage |
Number | 1 |
totalPages |
Number | 1 |
Style Overrides
There are no existing CSS variables for this component. Explore existing options, or propose a new one with a Component Proposal.
Events
The <nys-pagination> component emits one custom Javascript event:
nys-change– Fired when thecurrentPagevalue is changed.
Event details
The nys-change event includes a detail object with the following properties:
- id (string): The id of the pagination component.
- page (integer): The new value of
currentPage
You can listen to these events using JavaScript:
Suggest a New Component
Do you have an idea for a new NYS Design System web component? Look through the existing proposals in our GitHub discussions board to see if someone already proposed something similar. If not, feel free to submit one.
Edit this page on GitHub (Permissions required)
Last updated: July 11, 2026