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
When to use this component
- Use for search results, such as a professional license lookup that returns hundreds of matches across the state.
- Use for data tables, such as paginated case records, permit applications, or document listings.
- Use when performance matters. Pagination lets you fetch and render smaller data chunks instead of loading everything at once.
- Use when users need to navigate to a specific part of a result set, such as jumping to page 5 of an agency directory.
When to consider something else
- If the result set is short enough to display on a single page (fewer than 3-4 screen heights), show all items and skip pagination.
- When you need to show progress through a series of sequential tasks -- such as a benefits enrollment workflow -- use the
<nys-stepper>component instead. - For infinite-scroll patterns (e.g., a news feed), pagination is not the right fit.
Do
- Set
totalPagesbased on your data set and page size. UpdatecurrentPagein response tonys-changeevents. - Position the pagination component below the content it controls, so users see results before navigating.
- Scroll users to the top of the results area when they change pages, so they start reading from the beginning of the new page.
Don't
- Don't use pagination when content fits on a single scrollable page. Splitting short content across multiple pages adds unnecessary clicks.
- Don't use pagination for step-based workflows where users complete tasks in order. Use
<nys-stepper>instead. - Don't set
currentPageto a value greater thantotalPages. The component clamps the value automatically, but your application logic should prevent this.
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: May 28, 2026