Examples › Pagination
To enable pagination, set the following Mantine DataTable properties:
page: number
The current page number (1-based).onPageChange: (page: number) => void
A callback invoked when the user navigates to another page; receives the new page number.totalRecords: number | undefined
The total number of records in the dataset (used to compute the number of pages).recordsPerPage: number
The number of records per page.
You can customize the default pagination behavior and appearance with the following optional properties:
loadingText: string
The text displayed in the pagination footer while records are loading. Defaults to....noRecordsText: string
The text displayed when there are no records. Defaults toNo records. The same text is used by the empty state indicator.paginationText
A callback receiving an object in the shape of{ from: number; to: number; totalRecords: number }and returning aReactNoderepresenting the pagination text. By default, the text looks like1 - 15 / 500.paginationSize: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
The pagination size. Defaults tosm.paginationWrapBreakpoint: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | (string & {}) | number
A breakpoint below which the pagination footer content will wrap on multiple lines. Defaults tosm.
You can also provide astringlike'300px'or'20rem', or anumber, which is interpreted as a pixel value and converted torem.paginationActiveTextColor: MantineColor | { light: MantineColor; dark: MantineColor }
The text color of the active page button. Defaults to white.paginationActiveBackgroundColor: MantineColor | { light: MantineColor; dark: MantineColor }
The background color of the active page button. Defaults to the theme’s primary color.
Both color properties accept a MantineColor (a key of theme.colors or any valid CSS color string), or an object with light and dark keys, to use different colors for the light and dark color schemes.
Here is the code for the example above:
Displaying a page size selector
To let the user choose the page size, set the following properties:
recordsPerPageOptions: number[]
An array of page sizes to choose from.onRecordsPerPageChange: (recordsPerPage: number) => void
A callback invoked when the user selects another page size; receives the new page size.recordsPerPageLabel: string
The page size selector label. Defaults to'Records per page'.
Showing first and last page buttons
The pagination component shows “previous page” and “next page” buttons by default. Set paginationWithEdges to also show “first page” and “last page” buttons, or set paginationWithControls to false to hide the “previous” and “next” buttons:
Customizing pagination controls
You can fully customize the pagination footer by providing a renderPagination callback. It receives a context object with the following keys:
state: the current pagination state (page,totalPages,totalRecords,recordsPerPage,from,to,fetching,paginationSize,isWrapped, etc.);actions:setPageand, when the page size selector is enabled,setRecordsPerPage;Controls: factories for the default controls —Controls.Text(the pagination text),Controls.PageSizeSelector(the page size selector, if enabled) andControls.Pagination(the Mantine Pagination component). Each of them accepts optional props to override the defaults.
This allows you to render the controls in any order, inject your own elements, or override their props. The example below adds a “jump to page” input between the page size selector and the pagination component:
Jump to page
Passing props to pagination buttons
You can pass additional props to the pagination buttons with these callbacks:
getPaginationControlProps: receives the control type ('first','last','previous'or'next') and returns an object of props for that control;getPaginationItemProps: receives a page number and returns an object of props for the corresponding page button.
For instance, if you’re not happy with the default accessibility labels, you can override them like so:
Head over to the next example to discover more features.












