Pagination
Usage
Controlled
To control component state provide page and onChange props:
Siblings
Control amount of active item siblings with siblings prop:
Boundaries
Control amount of items displayed after previous and before next buttons with boundaries prop:
Styles API
You can use data-active attribute on item selector to change styles of selected item:
Accessibility
Pagination renders a div with the role of "navigation". Inside are regular button elements. To include aria-labels for screen reader support, you can provide an aria-label to the Pagination component itself.
To provide aria-labels to the actions inside the component, use the getItemAriaLabel function to generate aria-labels:
The current active page will have the attribute aria-current="page".
use-pagination hook
If you need more flexibility @mantine/hooks exports use-pagination hook, you can use it to create your own pagination component.
Pagination component props
| Name | Type | Description |
|---|---|---|
| align | AlignItems | Defines align-items css property |
| boundaries | number | Amount of elements visible on left/right edges |
| color | MantineColor | Active item color from theme, defaults to theme.primaryColor |
| disabled | boolean | Determines whether all controls should be disabled |
| getItemAriaLabel | (page: number | "first" | "last" | "dots" | "next" | "prev") => string | Callback to control aria-labels |
| grow | boolean | Defines flex-grow property for each element, true -> 1, false -> 0 |
| initialPage | number | Active initial page for uncontrolled component |
| itemComponent | FC<PaginationItemProps> | Change item component |
| noWrap | boolean | Defined flex-wrap property |
| onChange | (page: number) => void | Callback fired after change of each page |
| page | number | Controlled active page number |
| position | "left" | "right" | "center" | "apart" | Defines justify-content property |
| radius | number | "xs" | "sm" | "md" | "lg" | "xl" | Predefined item radius or number to set border-radius in px |
| siblings | number | Siblings amount on left/right side of selected page |
| size | number | "xs" | "sm" | "md" | "lg" | "xl" | Predefined item size or number to set width and height in px |
| spacing | number | "xs" | "sm" | "md" | "lg" | "xl" | Spacing between items from theme or number to set value in px, defaults to theme.spacing.xs / 2 |
| total * | number | Total amount of pages |
| withControls | boolean | Show/hide prev/next controls |
| withEdges | boolean | Show/hide jump to start/end controls |
Pagination component Styles API
| Name | Static selector | Description |
|---|---|---|
| item | .mantine-Pagination-item | Pagination items, dots and arrows |