Skip to content

Pagination ​

Navigation between the pages of a list or a table. The number of buttons stays constant (ellipses replace distant pages), so the bar keeps the same width from one page to the next.

Usage ​

Basic usage ​

From the total number of items (total) and the page size (pageSize, 10 by default), or directly with pageCount.

Page 1

vue
<script setup>
import { ref } from 'vue'

const page = ref(1)
</script>

<template>
  <SuPagination v-model="page" :total="200" :page-size="10" />
</template>

First and last page ​

vue
<SuPagination v-model="page" :page-count="20" show-edges />

Siblings and boundaries ​

siblings sets the number of pages on each side of the current page, boundaries the number of pages always shown at the start and end.

vue
<SuPagination v-model="page" :page-count="20" :siblings="2" :boundaries="2" />

Sizes ​

vue
<SuPagination v-model="page" :page-count="8" size="sm" />

API ​

Props ​

PropTypeDefaultDescription
modelValuenumber1Current page, from 1 to n (v-model)
totalnumber-Total number of items
pageSizenumber10Items per page
pageCountnumber-Number of pages, takes precedence over total / pageSize
siblingsnumber1Pages on each side of the current page
boundariesnumber1Pages always shown at the start and end
showEdgesbooleanfalseFirst / last page buttons
size'sm' | 'md' | 'lg''md'Size
disabledbooleanfalseDisables the pagination
ariaLabelstring'Pagination' (locale)Navigation name
previousLabel / nextLabelstring'Previous page' / 'Next page' (locale)Previous / next button names
firstLabel / lastLabelstring'First page' / 'Last page' (locale)Edge button names
pageLabel(page: number) => string'Page {page}'Page button name

Events ​

EventPayloadDescription
update:modelValuenumberNew page (v-model)
changenumberPage changed by the user

The page computation is exported on its own, for a custom pagination: import { getPaginationItems } from '@surgeui/ds-vue', then getPaginationItems({ page, count, siblings, boundaries }) returns the numbers and ellipses ('ellipsis-start', 'ellipsis-end').

Accessibility ​

  • <nav aria-label="Pagination"> containing a list; the current page has aria-current="page".
  • Each page button is named "Page 3": the name contains the visible number (WCAG 2.5.3).
  • On the first or last page, previous and next stay focusable with aria-disabled="true", so focus is not lost when the button becomes inactive.
  • Ellipses are hidden from screen readers.
  • In RTL, the chevrons are mirrored.

Publié sous licence MIT.