JGuang

Pagination

Pagination · Ant Design

Preview
npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23

Pagination

A long list can be divided into several pages, and only one page will be loaded at a time.

When To Use

  • When it will take a long time to load/render all items.
  • If you want to browse the data by navigating through pages.

Examples

  • Basic · basic

  • Align · align

  • More · more

  • Changer · changer

  • Jumper · jump

  • Size · mini

  • Simple mode · simple

  • Controlled · controlled

  • Total number · total

  • Show All · all

  • Prev and next · itemRender

  • Custom component · components

  • Custom semantic dom styling · style-class

API

Common props ref:Common props

<Pagination onChange={onChange} total={50} />
PropertyDescriptionTypeDefaultVersionGlobal Config
alignAlignstart | center | end-5.19.0×
classNamesCustomize class for each semantic structure inside the component. Supports object or functionRecord<SemanticDOM, string> | (info: { props }) => Record<SemanticDOM, string>-6.0.0
componentsCustomize internal components{ sizeChanger?: React.ComponentType }-6.6.0×
currentCurrent page numbernumber-×
defaultCurrentDefault initial page numbernumber1×
defaultPageSizeDefault number of data items per pagenumber10×
disabledDisable paginationboolean-×
hideOnSinglePageWhether to hide pager on single pagebooleanfalse×
itemRenderTo customize item's innerHTML(page, type: 'page' | 'prev' | 'next', originalElement) => React.ReactNode-×
pageSizeNumber of data items per pagenumber-×
pageSizeOptionsSpecify the sizeChanger optionsnumber[][10, 20, 50, 100]×
responsiveIf size is not specified, Pagination would resize according to the width of the windowboolean-×
showLessItemsShow less page itemsbooleanfalse×
showQuickJumperDetermine whether you can jump to pages directlyboolean | { goButton: ReactNode }false×
showSizeChangerDetermine whether to show pageSize selectboolean | SelectProps-SelectProps: 5.21.04.21.0, SelectProps: 5.21.0
showTitleShow page item's titlebooleantrue×
showTotalTo display the total number and rangefunction(total, range)-×
simpleWhether to use simple modeboolean | { readOnly?: boolean }-×
sizeComponent sizelarge | medium | smallmedium×
stylesCustomize inline style for each semantic structure inside the component. Supports object or functionRecord<SemanticDOM, CSSProperties> | (info: { props }) => Record<SemanticDOM, CSSProperties>-6.0.0
totalTotal number of data itemsnumber0×
totalBoundaryShowSizeChangerWhen total larger than it, showSizeChanger will be truenumber506.2.0
onChangeCalled when the page number or pageSize is changed, and it takes the resulting page number and pageSize as its argumentsfunction(page, pageSize)-×
onShowSizeChangeCalled when pageSize is changedfunction(current, size)-×

Semantic DOM

Semantic nodeNative descriptionVersion
rootRoot element, set flex layout, alignment, flex wrap and list styles6.0.0
itemItem element, set size, padding, border, background color, hover state and active state styles6.0.0

Semantic description source: vendor/components/pagination/demo/_semantic.tsx

Design Token

Types, inheritance and declarations retain the pinned native source. Defaults are computed by the native theme and may be overridden by ConfigProvider; this table does not invent static defaults.

TokenTypeNative description
itemBgstringBackground color of Pagination item
itemSizenumberSize of Pagination item
itemSizeSMnumberSize of small Pagination item
itemSizeLGnumberSize of large Pagination item
itemActiveBgstringBackground color of active Pagination item
itemActiveColorstringText color of active Pagination item
itemActiveColorHoverstringText color of active Pagination item hover
itemLinkBgstringBackground color of Pagination item link
itemActiveBgDisabledstringBackground color of disabled active Pagination item
itemActiveColorDisabledstringText color of disabled active Pagination item
itemInputBgstringBackground color of input
miniOptionsSizeChangerTopnumberTop of Pagination size changer

Declaration source: vendor/components/pagination/style/index.ts

import { unit } from '@ant-design/cssinjs';

import type { CSSObject } from '@ant-design/cssinjs';

import {
  genBasicInputStyle,
  genInputLargeStyle,
  genInputSmallStyle,
  initComponentToken,
  initInputToken,
} from '../../input/style';

import type { SharedComponentToken, SharedInputToken } from '../../input/style/token';

import { genBaseOutlinedStyle, genDisabledStyle } from '../../input/style/variants';

import { genFocusOutline, genFocusStyle, resetComponent } from '../../style';

import type { FullToken, GenerateStyle, GenStyleFn, GetDefaultToken } from '../../theme/internal';

import { genStyleHooks, mergeToken } from '../../theme/internal';

import { genCssVar } from '../../theme/util/genStyleUtils';

export interface ComponentToken {
  /**
   * @desc 页码选项背景色
   * @descEN Background color of Pagination item
   */
  itemBg: string;
  /**
   * @desc 页码尺寸
   * @descEN Size of Pagination item
   */
  itemSize: number;
  /**
   * @desc 小号页码尺寸
   * @descEN Size of small Pagination item
   */
  itemSizeSM: number;
  /**
   * @desc 大号页码尺寸
   * @descEN Size of large Pagination item
   */
  itemSizeLG: number;
  /**
   * @desc 页码激活态背景色
   * @descEN Background color of active Pagination item
   */
  itemActiveBg: string;
  /**
   * @desc 页码激活态文字颜色
   * @descEN Text color of active Pagination item
   */
  itemActiveColor: string;
  /**
   * @desc 页码激活态文字颜色悬停态
   * @descEN Text color of active Pagination item hover
   */
  itemActiveColorHover: string;
  /**
   * @desc 页码链接背景色
   * @descEN Background color of Pagination item link
   */
  itemLinkBg: string;
  /**
   * @desc 页码激活态禁用状态背景色
   * @descEN Background color of disabled active Pagination item
   */
  itemActiveBgDisabled: string;
  /**
   * @desc 页码激活态禁用状态文字颜色
   * @descEN Text color of disabled active Pagination item
   */
  itemActiveColorDisabled: string;
  /**
   * @desc 输入框背景色
   * @descEN Background color of input
   */
  itemInputBg: string;
  /**
   * @desc 每页展示数量选择器 top
   * @descEN Top of Pagination size changer
   */
  miniOptionsSizeChangerTop: number;
}

/**
 * @desc Pagination 组件的 Token
 * @descEN Token for Pagination component
 */
export interface PaginationToken
  extends FullToken<'Pagination'>, SharedComponentToken, SharedInputToken {
  /**
   * @desc 输入框轮廓偏移量
   * @descEN Outline offset of input
   */
  inputOutlineOffset: number;
  /**
   * @desc 快速跳转输入框宽度
   * @descEN Width of quick jumper input
   */
  quickJumperInputWidth: number | string;
  /**
   * @desc 迷你选项横向外边距
   * @descEN Horizontal margin of mini options
   */
  paginationMiniOptionsMarginInlineStart: number | string;
  /**
   * @desc 迷你快速跳转输入框宽度
   * @descEN Width of mini quick jumper input
   */
  paginationMiniQuickJumperInputWidth: number | string;
  /**
   * @desc 页码横向内边距
   * @descEN Horizontal padding of Pagination item
   */
  paginationItemPaddingInline: number | string;
  /**
   * @desc 省略号字母间距
   * @descEN Letter spacing of ellipsis
   * @deprecated Ellipsis is now an SVG icon, this token is no longer used.
   */
  paginationEllipsisLetterSpacing: number | string;
  /**
   * @desc 省略号文本缩进
   * @descEN Text indent of ellipsis
   * @deprecated Ellipsis is now an SVG icon, this token is no longer used.
   */
  paginationEllipsisTextIndent: string;
  /**
   * @desc 斜杠横向外边距
   * @descEN Horizontal margin of slash
   */
  paginationSlashMarginInlineStart: number;
  /**
   * @desc 斜杠横向外边距
   * @descEN Horizontal margin of slash
   */
  paginationSlashMarginInlineEnd: number;
}

Shared native props

Tips: The following generic properties apply to most antd components; those not supported are described separately.

PropertyDescriptionTypeDefault
styleThe additional styleCSSProperties-
classNameThe additional css classstring-
rootClassNameClassName on the root elementstring-
autoFocusAuto focus when component mounted, only effective for focusable elements like forms, links, etc.booleanfalse

Install and reproduce an example

npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23

Use ConfigProvider and native App; configure dayjs locale separately. Each example lists its complete source files and additional pinned dependencies in View code. Example names select demos, not universal component props. See the resource setup guide for theme, locale and SSR.

Native type references

The source viewer includes unchanged native implementations and the following source declarations. Inherited types remain in their native packages. English source comments are preserved as code reference.

  • vendor/components/pagination/Pagination.tsx
  • vendor/components/pagination/style/index.ts

Source and license

https://github.com/ant-design/ant-design/tree/4a39f54842eade4e565ab336ef6097cd7e723cdd

Original bilingual prose and executable examples are retained. Website-only embeds and token tables are expanded locally. Ant Design is MIT; separately listed dependency notices also apply. Upload previews block outbound requests and do not provide a backend.