Pagination
Splits a large result set into pages and provides controls for navigating them.
On this page
This docs is LLM-friendly and available as clean Markdown.
Supported browser agents can also use WebMCP to search, read, and open these docs. Learn more
Usage
import { GlPagination } from "gitlab-ui-react/pagination";
import { GlKeysetPagination } from "gitlab-ui-react/keyset-pagination";<GlPagination perPage={20} totalItems={100} value={1} />Default
Use offset pagination when the total size is known and users benefit from jumping to a numbered page. Update value through onValueChange for button-like navigation, or provide linkGen for real page URLs.
Offset pagination
import { useState } from "react";
import { GlPagination } from "gitlab-ui-react/pagination";
export default function PaginationExample() {
const [page, setPage] = useState(3);
return (
<GlPagination
perPage={10}
totalItems={200}
value={page}
onValueChange={setPage} />
);
}
Keyset pagination
Use keyset pagination for cursor-based data that can change while the user moves through it. It provides only Previous and Next controls and passes the relevant cursor to each callback.
Keyset pagination
import { useState } from "react";
import { GlKeysetPagination } from "gitlab-ui-react/keyset-pagination";
export default function KeysetPaginationExample() {
const [page, setPage] = useState(1);
return (
<GlKeysetPagination
endCursor={`page-${page}`}
hasNextPage={page < 4}
hasPreviousPage={page > 1}
startCursor={`page-${page}`}
onNext={() => setPage((current) => current + 1)}
onPrevious={() => setPage((current) => current - 1)} />
);
}
Accessibility
- Give each pagination landmark a localized and descriptive
labelNavornavigationLabel, especially when more than one appears on a page. - Keep page and control labels localized. Numbered pagination marks the active link with
aria-current="page"automatically. - After loading a new page, move focus and scroll position to the start of the updated content when appropriate.
- Prefer links with real destinations when each page has a stable URL.
API
Both components forward supported attributes to the rendered <nav> element.
GlPagination
| Prop | Description | Default |
|---|---|---|
value |
Sets the current page number. | 1 |
perPage |
Sets the number of items per page. | 20 |
totalItems |
Sets the total number of available items. | 0 |
onValueChange |
Reports a requested page change when linkGen is not set. |
— |
linkGen |
Generates a URL for each page and enables link-based navigation. | null |
align |
Aligns controls to left, center, right, or fill. |
"left" |
limits |
Sets the maximum visible page links by viewport breakpoint. | { xs: 0, sm: 3, md: 9, default: 9 } |
labelNav |
Labels the pagination navigation landmark. | "Pagination" |
labelPage |
Sets or generates each numbered page link’s accessible label. | "Go to page %{page}" |
prevPage |
Enables compact pagination with a previous page marker. | null |
nextPage |
Enables compact pagination with a next page marker. | null |
GlKeysetPagination
| Prop | Description | Default |
|---|---|---|
hasPreviousPage |
Enables the Previous control. | false |
hasNextPage |
Enables the Next control. | false |
startCursor |
Passes the first-item cursor to onPrevious. |
null |
endCursor |
Passes the last-item cursor to onNext. |
null |
onPrevious |
Runs when the enabled Previous control is activated. | — |
onNext |
Runs when the enabled Next control is activated. | — |
prevText |
Sets the Previous control text. | "Previous" |
nextText |
Sets the Next control text. | "Next" |
navigationLabel |
Labels the pagination navigation landmark. | "Pagination" |
disabled |
Disables both controls. | false |