Examples › Pagination
You can enable pagination by setting the following Mantine DataTable properties:
page: number
The current page number.onPageChange
A callback that is executed when the user changes the current page.totalRecords: number
The total number of records in the dataset.recordsPerPage: number
The number of records per page.
1 - 15 / 500
No records
If you’re not happy with the default pagination behavior, you can override it by setting these optional properties:
loadingText: string
A text to display while loading records.noRecordsText: string
A text to display when no records are present.paginationText
A callback receiving an object in the shape of{ from: number; to: number; totalRecords: number }
and returning aReactNode
representing the pagination text.paginationSize: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
The pagination size.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 astring
like'300px'
or'20rem'
, or anumber
, in which case it will be interpreted as a pixel value and converted to rem value before being applied.paginationActiveTextColor: MantineColor | { light: MantineColor; dark: MantineColor }
Color applied to active page button text.
Can be aMantineColor
(key oftheme.colors
or any valid CSS color string), or an object withlight
anddark
keys andMantineColor
values.
Defaults to white.paginationActiveBackgroundColor: MantineColor | { light: MantineColor; dark: MantineColor }
Color applied to active page button background.
Can be aMantineColor
(key oftheme.colors
or any valid CSS color string), or an object withlight
anddark
keys andMantineColor
values.
Defaults to primary theme color.
Here is the code:
Displaying a page size selector
You can display a selector to let the user choose the page size by setting the following component properties:
recordsPerPageOptions: number[]
An array of page size numbers to display in the page size selector.onRecordsPerPageChange
A callback that is executed when the user changes the page size. Receives the new page size as its argument.recordsPerPageLabel
The page size selector label, defaulting to 'Records per page'.
1 - 15 / 500
Records per page
No records
Using pagination control props
You can provide additional props to pagination controls by using the getPaginationControlProps
callback. For example, if you’re not happy with the default accessibility aria-labels, you can override them like so:
1 - 15 / 500
No records
Head over to the next example to discover more features.