<cs-pagination>
ExperimentalNavigationSince 0.1

Pagination splits long lists of content into pages, letting users navigate between them.

Set total and page-size to generate numbered page buttons with previous and next controls. Use the label attribute to give the control an accessible name, which is especially helpful when more than one appears on the same page.

Pagination is a navigation control, not a form control.
It tracks the current page and emits events, but it doesn’t submit a value with a form. Keep page in sync with your data by updating it in response to the cs-after-page-change event.

Examples

Appearance

Set the appearance attribute to change the pagination’s visual style. Valid appearances are outlined (the default), filled, and plain.

Size

Pagination has no size attribute; set font-size on the control or any ancestor to scale it.

Number of Buttons

Use the sibling-count attribute to set how many pages show on each side of the current page (defaults to 2), and boundary-count to set how many show at the start and end (defaults to 1). Remaining pages collapse into an ellipsis, which jumps several pages toward that side when activated.

First and Last Buttons

Add the with-edges attribute to show buttons that jump to the first and last pages.

Previous and Next Buttons

Add the without-nav attribute to hide the previous and next buttons, leaving only the page numbers.

Summary

Add the with-summary attribute to show a summary of the items on the current page.

Compact

Set the format attribute to compact to replace the page numbers with a short “1 of 5” label between the previous and next buttons.

The compact format can be combined with other features, such as with-summary:

Custom Icons

Use the previous-icon, next-icon, first-icon, and last-icon slots to replace the default navigation icons.

Replacing an icon doesn’t replace its label.
The navigation buttons keep their built-in accessible labels, so screen readers still announce them correctly.

Disabled

Add the disabled attribute to disable the entire pagination control.

Single Page

Add the hide-single-page attribute to render nothing when there’s only one page of results. Since a single page renders nothing, this example is shown as code rather than a live preview.

<cs-pagination total="5" page-size="10" hide-single-page></cs-pagination>

Page Size Selector

Pair a select with the pagination control to let users change the page size. Update page-size when the selection changes, and reset to the first page.

10 20 50 100

Responding to Page Changes

When the user changes the page, the cs-after-page-change event is emitted with { page, pageSize } in event.detail. Update the page property to reflect the new page and load the corresponding data.

Showing page 1

Setting the Page Programmatically

Set the page property to any valid page to change the current page without user interaction. Setting page directly doesn’t emit cs-after-page-change.

Page 1 Page 5 Page 10

Preventing a Page Change

Call event.preventDefault() on the cs-page-change event to cancel a page change, such as to guard against unsaved changes.

Set the href-template attribute to render page items as links instead of buttons, using {page} as a placeholder for the page number. Every control links through the template, which works well for server-rendered pages.

In JavaScript, you can also set the hrefTemplate property to a function that receives the page number and returns the URL. This is handy when the URL doesn’t follow a simple substitution. When server-rendering, set the href-template attribute to the closest equivalent as well, so the server and the browser render the same markup.

In link mode, the component navigates instead of updating itself.
Render it on the server with the correct page for each request. Disabled and boundary controls, such as previous on the first page, render as anchors with no href and aria-disabled set.

Customizing

Use the exported CSS parts to customize the pagination’s appearance, where the button part targets every button at once. The plain appearance is a good starting point.

This example turns the control into a row of pill-shaped buttons, gives the navigation arrows a colorful circular treatment, and highlights the current page with a gradient and a soft glow.

Accessibility Considerations

Pagination ships with several accessibility behaviors built in:

  • Page changes are announced. When the page changes, the new position is announced to screen readers through a shared live region, so the update isn’t silent.
  • Focus follows the page. After a control is activated, focus moves to the new current page rather than falling back to the top of the document, keeping keyboard users oriented.
  • The current page is marked. The active page carries aria-current="page", and disabled or boundary controls carry aria-disabled so assistive technology skips them.
  • Icons are direction-aware. The previous, next, first, and last icons flip automatically in right-to-left languages.

Give the control an accessible name with the label attribute whenever more than one pagination appears on a page, so screen reader users can tell them apart.

API

Importing

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick this component, use one of the following snippets.

npm Self-Hosted React
import '@cruglobal/cornerstone-components/components/pagination/pagination.js';
import './cornerstone/components/pagination/pagination.js';
import CsPagination from '@cruglobal/cornerstone-components/react/pagination/index.js';

Slots

Learn more about using slots.

NameDescription
first-iconAn icon to use in lieu of the default first icon.
last-iconAn icon to use in lieu of the default last icon.
next-iconAn icon to use in lieu of the default next icon.
previous-iconAn icon to use in lieu of the default previous icon.

Attributes & Properties

Learn more about attributes and properties.

PropertyAttributeDescriptionTypeDefaultReflects
appearanceappearanceThe pagination's visual appearance.'outlined' | 'filled' | 'plain''outlined'Yes
boundaryCountboundary-countThe number of pages to always show at the start and end.number1
disableddisabledDisables the pagination.booleanfalseYes
formatformatThe pagination's layout. The default standard format shows the full page list with ellipses; compact collapses it into a short "1 of 5" label flanked by the previous and next buttons, useful in tight spaces like toolbars and cards.'standard' | 'compact''standard'Yes
hideSinglePagehide-single-pageRenders nothing when there's only one page.booleanfalse
hrefTemplatehref-templateA URL template used to render page items as links instead of buttons. When set, items render as <a> elements for SSR, SEO, and no-JS support. Provide a string with {page} as a placeholder for the page number, e.g. /products?page={page}. In JavaScript, you can also assign a function that receives the page number and returns the URL, e.g. el.hrefTemplate = page => \/products?page=${page}``.string | ((page: number) => string)''
labellabelA label that describes the pagination to assistive devices. This won't be shown on the screen, but it will be announced by screen readers. Especially useful when more than one pagination control exists on the same page.string''
pagepageThe current page, starting at 1.number1Yes
pageSizepage-sizeThe number of items shown per page.number10
siblingCountsibling-countThe number of pages to show on each side of the current page.number2
totaltotalThe total number of items to paginate.number0
totalPagesThe total number of pages, derived from total and pageSize.
withEdgeswith-edgesShows buttons that jump to the first and last pages.booleanfalse
withoutNavwithout-navHides the previous and next buttons.booleanfalse
withSummarywith-summaryShows a summary of the items on the current page, e.g. "1–10 of 237".booleanfalse

Events

Learn more about events.

NameDescription
cs-after-page-changeEmitted after the page changes.
cs-page-changeEmitted when the page is about to change but before it does. Canceling this event with event.preventDefault() prevents the page from changing.

Custom States

Learn more about custom states.

NameDescriptionCSS selector
disabledApplied when the pagination is disabled.:state(disabled)

CSS Parts

Learn more about CSS parts.

NameDescriptionCSS selector
buttonEvery button or link, including page numbers and navigation controls.::part(button)
ellipsisAn ellipsis for collapsed pages. Acts as a button that jumps several pages toward that side.::part(ellipsis)
first-buttonThe first button.::part(first-button)
labelThe "1 of 5" label shown between the navigation buttons in the compact layout.::part(label)
last-buttonThe last button.::part(last-button)
next-buttonThe next button.::part(next-button)
pageA page number button or link.::part(page)
page-currentThe current page number button or link.::part(page-current)
pagesThe list that wraps the page number items.::part(pages)
paginationThe component's outer wrapper, a <nav> element.::part(pagination)
previous-buttonThe previous button.::part(previous-button)
summaryThe summary of items on the current page, shown with the with-summary attribute.::part(summary)

Dependencies

This component automatically imports the following elements. Sub-dependencies, if any exist, are included in this list.