Skip to content

Pagination API Reference

Props

PropTypeDefaultDescription
modelValueNumber1Current page number (v-model)
totalPagesNumber-Total number of pages (required)
totalVisibleNumber7Maximum number of page buttons to show
showFirstLastBooleantrueShow first and last page buttons
showPrevNextBooleantrueShow previous and next page buttons
disabledBooleanfalseDisable all pagination controls
sizeString'default'Size variant. Options: 'small', 'default', 'large'
roundedBoolean/StringfalseApply rounded styling to buttons
colorString'primary'Color theme. Options: 'primary', 'secondary', 'success', 'error', 'warning', 'info'

Events

EventPayloadDescription
update:modelValueNumberEmitted when current page changes
firstNumberEmitted when first page button is clicked (page 1)
prevNumberEmitted when previous page button is clicked
nextNumberEmitted when next page button is clicked
lastNumberEmitted when last page button is clicked

Slots

SlotPropsDescription
first{ icon, onClick, disabled, ariaLabel, ariaDisabled }Custom first page button
prev{ icon, onClick, disabled, ariaLabel, ariaDisabled }Custom previous page button
next{ icon, onClick, disabled, ariaLabel, ariaDisabled }Custom next page button
last{ icon, onClick, disabled, ariaLabel, ariaDisabled }Custom last page button
item{ isActive, page, props }Custom page number button

Slot Props

  • icon: Default SVG icon component
  • onClick: Function to handle button click
  • disabled: Boolean indicating if button is disabled
  • ariaLabel: Accessibility label for the button
  • ariaDisabled: Boolean for aria-disabled attribute

Item Slot

  • isActive: Boolean indicating if this page is currently active
  • page: Page number
  • props: Object containing button props (class, aria-label, aria-current, onClick, disabled)

Computed Properties

PropertyTypeDescription
isFirstDisabledBooleanWhether first page button is disabled
isPrevDisabledBooleanWhether previous page button is disabled
isNextDisabledBooleanWhether next page button is disabled
isLastDisabledBooleanWhether last page button is disabled
visiblePageNumbersArrayArray of page numbers and ellipsis to display

Example Usage

vue
<template>
  <OPagination
    v-model="currentPage"
    :total-pages="totalPages"
    :total-visible="5"
    size="large"
    color="success"
    @first="handleFirst"
    @prev="handlePrev"
    @next="handleNext"
    @last="handleLast"
  >
    <template #item="{ isActive, page, props }">
      <button
        v-bind="props"
        :class="{ 'custom-active': isActive }"
      >
        {{ page }}
      </button>
    </template>
  </OPagination>
</template>

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

const currentPage = ref(1)
const totalPages = ref(20)

const handleFirst = (page) => {
  console.log('First page clicked:', page)
}

const handlePrev = (page) => {
  console.log('Previous page clicked:', page)
}

const handleNext = (page) => {
  console.log('Next page clicked:', page)
}

const handleLast = (page) => {
  console.log('Last page clicked:', page)
}
</script>