Pagination

Page-number navigation for paging a list of arbitrary items (e.g. a blog index), with ellipsis ranges and optional first/last/prev/next controls.

Demos

For usage examples, visit the component demo page: Pagination

Import

import { Pagination } from '@soroush.tech/design-system/Pagination'

Props

PropTypeDefaultDescription
countnumber-Total number of pages. Required.
pagenumber-Controlled current page (1-based).
defaultPagenumber1Uncontrolled initial page.
onChange(page: number) => void-Fired with the target page.
siblingCountnumber1Pages always visible either side of the current page.
boundaryCountnumber1Pages always visible at the start and end.
colorkeyof Theme['palette']'primary'Selected-item color.
variant'text' | 'outlined''text'Item style.
shape'circular' | 'rounded''circular'Item corner shape.
sizekeyof Theme['sizes']'md'Item density.
disabledbooleanfalseDisables every item.
shouldShowFirstButton / shouldShowLastButtonbooleanfalseAdds first/last-page buttons.
shouldHidePrevButton / shouldHideNextButtonbooleanfalseRemoves the previous/next buttons.
getItemAriaLabel(type, page, isSelected) => stringbuilt-inAccessible name per item ("Go to page 3", "Go to next page", ...).
aria-labelstring'pagination navigation'Landmark label.

usePagination

The headless model is exported for custom renderings:

import { usePagination } from '@soroush.tech/design-system/Pagination'

const { items } = usePagination({ count: 10, onChange })
// items: [{ type: 'previous', page, isSelected, isDisabled, onClick }, { type: 'page', ... }, ...]

Source code

If this page does not answer your question, have a look at the implementation of the component for more detail.