Skip to main content

CnPagination

Full pagination bar with page navigation, ellipsis for large page counts, and a page-size selector. Automatically hidden when all items fit on one page.

Wraps: NcButton, NcSelect

Try it

Loading CnPagination playground…

CnPagination showing "Page 1 of 2" with First/Previous/page numbers/Next/Last buttons and Items per page selector

Anatomy

+-----------------------------------------------------------------------+
| Page 1 of 8 | [First] [Previous] [1] [2] [3] … [8] [Next] [Last] | Items per page: [20 ▾]
+-----------------------------------------------------------------------+
↑ ↑ ↑ ↑ ↑ ↑
page info jump to prev/next page number jump to items per
first/last buttons buttons first/last page selector
RegionDescription
Page info"Page N of N" — current page and total pages
First / LastJump directly to the first or last page; disabled when already there
Previous / NextMove one page back or forward; disabled at the boundaries
Page numbersClickable page buttons; active page is highlighted. Shows up to 7 buttons with ellipsis for large datasets
Items per pageDropdown to change the page size; emits page-size-changed

Usage

<CnPagination
:current-page="pagination.currentPage"
:total-pages="pagination.totalPages"
:total-items="pagination.totalItems"
:current-page-size="pagination.pageSize"
@page-changed="onPageChanged"
@page-size-changed="onPageSizeChanged" />

Props

PropTypeDefaultDescription
currentPageNumber1The currently active page (1-based)
totalPagesNumber1Total number of pages
totalItemsNumber0Total number of items across all pages — used for the page info label
currentPageSizeNumber20Currently selected number of items per page
pageSizeOptionsArray[{ value: 10, label: '10' }, { value: 20, label: '20' }, …]Options shown in the "Items per page" dropdown. Each entry must be { value: number, label: string }
minItemsToShowNumber10Minimum item count before the pagination bar is rendered; hides it when all items fit on one page
firstLabelString'First'Accessible label for the First button
previousLabelString'Previous'Accessible label for the Previous button
nextLabelString'Next'Accessible label for the Next button
lastLabelString'Last'Accessible label for the Last button
itemsPerPageLabelString'Items per page:'Label preceding the page-size dropdown
pageInfoFormatString'Page {current} of {total}'Format string for the page info text; {current} and {total} are replaced at runtime

Events

EventPayloadDescription
page-changedpageNumEmitted when the user navigates to a different page; payload is the new 1-based page number
page-size-changedsizeEmitted when the user selects a different page size

Reference (auto-generated)

The tables below are generated from the SFC source via vue-docgen-cli. They reflect what's actually in CnPagination.vue and update automatically whenever the component changes.

Props

NameTypeRequiredDefaultDescription
currentPagenumber1Current page number (1-based)
totalPagesnumber1Total number of pages
totalItemsnumber0Total number of items across all pages
currentPageSizenumber20Current items per page
pageSizeOptionsarray[ \{ value: 10, label: '10' \}, \{ value: 20, label: '20' \}, \{ value: 50, label: '50' \}, \{ value: 100, label: '100' \}, \{ value: 250, label: '250' \}, \{ value: 500, label: '500' \}, \{ value: 1000, label: '1000' \}, ]Available page size options
minItemsToShownumber10Minimum items before pagination is shown
firstLabelstring() =&gt; t('nextcloud-vue', 'First')Label for "First" button
previousLabelstring() =&gt; t('nextcloud-vue', 'Previous')Label for "Previous" button
nextLabelstring() =&gt; t('nextcloud-vue', 'Next')Label for "Next" button
lastLabelstring() =&gt; t('nextcloud-vue', 'Last')Label for "Last" button
itemsPerPageLabelstring() =&gt; t('nextcloud-vue', 'Items per page:')Label for "Items per page:"
pageInfoFormatstring() =&gt; t('nextcloud-vue', 'Page \{current\} of \{total\}')Page info format string. Use {current} and {total} as placeholders. "Page {current} of {total}"

Events

NamePayloadDescription
page-changedEmitted when page changes. Payload: new page number.
page-size-changedEmitted when page size changes. Payload: new page size.