Skip to content

Repository files navigation

@rc-component/pagination

Ant Design Part of the Ant Design ecosystem.

📄 React pagination primitives for page navigation, size changing, quick jumping, and locale-aware controls.

NPM versionnpm downloadsbuild statusCodecovbundle sizedumi

English | 简体中文

Highlights

  • Controlled and uncontrolled pagination state.
  • Page-size changer, quick jumper, simple mode, compact item count, and custom item rendering.
  • Locale packages exposed from @rc-component/pagination/locale/*.
  • Semantic classNames and styles for item-level customization.
  • TypeScript definitions for props, locale, callbacks, and state.
  • Used by Ant Design as the shared pagination foundation.

Install

npm install @rc-component/pagination

Usage

importPaginationfrom'@rc-component/pagination';import'@rc-component/pagination/assets/index.css';exportdefault()=>(<PaginationdefaultCurrent={1}total={120}showSizeChangershowQuickJumper/>);
importPaginationfrom'@rc-component/pagination';importenUSfrom'@rc-component/pagination/locale/en_US';exportdefault()=>(<PaginationdefaultCurrent={2}total={500}locale={enUS}showTotal={(total,range)=>`${range[0]}-${range[1]} of ${total} items`}/>);

Examples

Run the local dumi site:

npm install
npm start

Then open http://localhost:8000.

API

Pagination

PropertyTypeDefaultDescription
align'start' | 'center' | 'end'-Align pagination items.
classNamestring-Class name for the root element.
classNamesPartial<Record<'item', string>>-Semantic class names.
currentnumber-Controlled current page.
defaultCurrentnumber1Initial current page.
defaultPageSizenumber10Initial page size.
disabledbooleanfalseDisable pagination interactions.
hideOnSinglePagebooleanfalseHide when there is only one page.
itemRender(page, type, element) => ReactNode-Customize page, previous, next, and jump items.
jumpNextIconReactNode | ComponentType-Custom next-jump icon.
jumpPrevIconReactNode | ComponentType-Custom previous-jump icon.
localePaginationLocalezh_CNLocale text.
nextIconReactNode | ComponentType-Custom next icon.
pageSizenumber-Controlled page size.
pageSizeOptionsnumber[]-Page-size options.
prefixClsstringrc-paginationClass name prefix.
prevIconReactNode | ComponentType-Custom previous icon.
roleReact.AriaRole-WAI-ARIA role.
selectPrefixClsstringrc-selectPrefix for the size changer select.
showLessItemsbooleanfalseShow fewer page items.
showPrevNextJumpersbooleantrueShow previous and next jumpers.
showQuickJumperboolean | objectfalseShow quick page jumper.
showSizeChangerbooleantotal > totalBoundaryShowSizeChangerShow page-size changer.
showTitlebooleantrueShow title on page items.
showTotal(total, range) => ReactNode-Render total text.
simpleboolean | { readOnly?: boolean }falseUse simple pager.
sizeChangerRenderSizeChangerRender-Customize the size changer.
styleReact.CSSProperties-Root inline style.
stylesPartial<Record<'item', CSSProperties>>-Semantic styles.
totalnumber0Total item count.
totalBoundaryShowSizeChangernumber50Boundary for default showSizeChanger.
onChange(page: number, pageSize: number, info?: { recommendPage?: number }) => void-Triggered when page or page size changes. The info.recommendPage is only provided when pageSize changes, indicating the recommended page number based on the new page size.
onShowSizeChange(current: number, size: number) => void-Triggered when page size changes.

Development

npm install
npm start
npm test
npm run tsc
npm run coverage
npm run compile
npm run build

The dumi site runs at http://localhost:8000 by default.

Release

npm run prepublishOnly

The release flow is handled by @rc-component/np through the rc-np command after the package build.

License

@rc-component/pagination is released under the MIT license.

About

📄 React pagination primitives for page navigation, size changing, quick jumping, and locale-aware controls.

Topics

Resources

Stars

676 stars

Watchers

25 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages