Skip to content

CdsPagination

Pagination splits a large data set into pages and helps you jump to the one you need: numbered buttons, "back" and "forward" arrows, jumps to the first and the last page, and a quick jump field. Extra numbers collapse into an ellipsis, and without an explicit limit the number of buttons adapts to the width of the container.

Storybook GitLab Figma
Test coverage: 100% — good coverage
API in specs
39 / 39 props, events, slots and exposed members with a test
Test cases
54 unit · 0 browser
Known bugs
5 pinned by an it.fails test
Code coverage
100% lines · 96.7% branches measured in v4.0.0-alpha.13
A11y (axe)
8 recommendations in 11 stories measured in v4.0.0-alpha.11

Pagination pages through homogeneous data — a list or a table. To switch between sections of the interface use CdsTabs, and to navigate the hierarchy of pages use CdsBreadcrumbs.

Anatomy ​

Pagination is a row of page buttons with arrows on the sides. The first and last page buttons appear with show-first-last-page, the quick jump field with quick-jumper, and the pages between the edges and the neighbors of the current one collapse into an ellipsis.

Variations ​

Number of pages ​

The length prop sets the number of pages, v-model holds the number of the current one. While the focus is inside the pagination, the ← and → keys page through.

Visible buttons ​

The total-visible prop limits how many buttons are visible at once — the remaining pages collapse into an ellipsis (its text is changed by the ellipsis prop). Without total-visible the component counts how many buttons fit into the container itself and collapses the extra ones.

Edge pages ​

The show-first-last-page prop adds buttons that jump to the first and the last page. The only-first value keeps just the first page button — handy when the total number of pages is unknown or only approximate.

Quick jump ​

The quick-jumper prop adds a field where the user types a page number and gets there on Enter or on blur. The label before the field is changed by the quick-jumper-label prop.

Disabled state ​

The disabled prop blocks the whole navigation — while the current page is loading, for example.

Slots ​

Slots replace the default buttons while keeping the switching logic: every slot receives a ready onClick handler and the disabled state.

SlotDescription
itemA single page button; props carries everything to pass to it
firstButton that jumps to the first page
prevButton that jumps to the previous page
nextButton that jumps to the next page
lastButton that jumps to the last page

Guidelines ​

Scenarios ​

Paged list ​

The classic pairing: the list shows the slice of data for the current page, the "Показано 1–4 из 23" caption gives a sense of the total, and total-visible="3" keeps the pagination compact next to the counter.

Loading pages from the server ​

When the data comes from the server, watch v-model (or the first / prev / next / last / quickJump events) and fire the request on a page change. While the request is in flight, disabled blocks the pagination and guards against extra switches.

Search with a page reset ​

Filtering recalculates the number of pages and resets the current page to the first one — otherwise the user may end up on a page that no longer exists. When the results fit on a single page, the pagination hides.

API ​

Props

NameTypeDefaultDescription
activeColorstring | undefined—Color of the active page button
ariaLabelstring | undefined'Навигация по страницам'ARIA label of the root navigation element
colorstring | undefined—Color of the page buttons
currentPageAriaLabelstring | undefined'Текущая страница, страница {0}'ARIA label of the current (active) page. {0} is replaced with the page number
disabledboolean | null | undefinednullDisabled state
ellipsisstring | undefined'...'Text displayed between pages when they are collapsed
firstAriaLabelstring | undefined'Первая страница'ARIA label of the first page button
firstIconIconValue | undefined'first-page'Icon of the first page button
lastAriaLabelstring | undefined'Последняя страница'ARIA label of the last page button
lastIconIconValue | undefined'last-page'Icon of the last page button
lengthstring | number | undefined1Number of pages
modelValuenumber | undefined(props) => props.startThe v-model value — the number of the current page
nextAriaLabelstring | undefined'Следующая страница'ARIA label of the next page button
nextIconIconValue | undefined'chevron-right'Icon of the next page button
pageAriaLabelstring | undefined'Перейти к странице {0}'ARIA label of a page button. {0} is replaced with the page number
prevIconIconValue | undefined'chevron-left'Icon of the previous page button
previousAriaLabelstring | undefined'Предыдущая страница'ARIA label of the previous page button
quickJumperboolean | undefinedfalseShows the quick jump field
quickJumperLabelstring | undefined'Перейти к странице'Caption text before the quick jump field
showFirstLastPageboolean | "only-first" | undefinedfalseShows the first/last page buttons. 'only-first' shows only the first page button
startstring | number | undefined1Initial page
tagstring | JSXComponent<any> | undefined'nav'Custom HTML tag or component to render
themestring | undefined—Component theme
totalVisiblestring | number | undefined—Number of page buttons visible at once

Events

NameTypeDescription
first[value: number]Fired on a jump to the first page
last[value: number]Fired on a jump to the last page
next[value: number]Fired on a jump to the next page
prev[value: number]Fired on a jump to the previous page
quickJump[value: number]Fired on a jump made through the quick jump field
update:modelValue[value: number]Fired when the v-model value changes

Slots

NameTypeDescription
firstCdsPaginationControlSlotSlot of the first page button
itemCdsPaginationItemSlotSlot of a single page button
lastCdsPaginationControlSlotSlot of the last page button
nextCdsPaginationControlSlotSlot of the next page button
prevCdsPaginationControlSlotSlot of the previous page button

Exposed

NameTypeDescription
setFirst() => voidJumps to the first page.
setLast() => voidJumps to the last page.
setNext() => voidJumps to the next page.
setPrev() => voidJumps to the previous page.