Skip to content

PubPagination

This is a pagination component which can be used to paginate through a list of items.

Default Usage

vue
<template>
    <pub-pagination v-model="currentPage" :total-items="100" />
    <pub-pagination v-model="currentPage" :total-items="100" size="md" />
</template>

<script lang="ts" setup>
import { PubPagination } from "vuelicity";
import { ref } from "vue";

const currentPage = ref(1);
</script>

Pagination with icons

vue
<template>
    <pub-pagination v-model="currentPage" :total-items="100" hide-labels show-icons />
    <pub-pagination v-model="currentPage" :total-items="100" hide-labels show-icons size="lg" />
</template>

<script lang="ts" setup>
import { PubPagination } from "vuelicity";
import { ref } from "vue";

const currentPage = ref(1);
</script>

Custom length pagination

vue
<template>
    <pub-pagination v-model="currentPage" :slice-size="4" :total-pages="100" />
</template>

<script lang="ts" setup>
import { PubPagination } from "vuelicity";
import { ref } from "vue";

const currentPage = ref(5);
</script>

Previous and Next

vue
<template>
    <pub-pagination v-model="currentPage" layout="navigation" :total-pages="100" />
    <pub-pagination v-model="currentPage" layout="navigation" :total-pages="100" size="md" />
</template>

<script lang="ts" setup>
import { PubPagination } from "vuelicity";
import { ref } from "vue";

const currentPage = ref(1);
</script>

Previous and Next with icons

vue
<template>
    <pub-pagination v-model="currentPage" layout="navigation" :total-pages="100" show-icons />
    <pub-pagination
        v-model="currentPage"
        layout="navigation"
        :total-pages="100"
        show-icons
        size="lg"
    />
</template>

<script lang="ts" setup>
import { PubPagination } from "vuelicity";
import { ref } from "vue";

const currentPage = ref(1);
</script>

First and Last

vue
<template>
    <pub-pagination v-model="currentPage" :total-pages="100" show-first-last />
    <pub-pagination v-model="currentPage" :total-pages="100" show-first-last size="md" />
    <pub-pagination v-model="currentPage" :total-pages="100" show-first-last show-icons />
</template>

<script lang="ts" setup>
import { PubPagination } from "vuelicity";
import { ref } from "vue";

const currentPage = ref(1);
</script>

Table data pagination

vue
<template>
    <pub-pagination v-model="currentPage1" layout="table" :page-size="20" :total-items="100" />
    <pub-pagination v-model="currentPage2" layout="table" :page-size="100" :total-items="550" size="md" />
</template>

<script lang="ts" setup>
import { PubPagination } from "vuelicity";
import { ref } from "vue";

const currentPage1 = ref(1);
const currentPage2 = ref(1);
</script>

Pagination with custom labels

vue
<template>
    <pub-pagination v-model="currentPage" :total-pages="100" prev-label="<<<" next-label=">>>" />
</template>

<script lang="ts" setup>
import { PubPagination } from "vuelicity";
import { ref } from "vue";

const currentPage = ref(1);
</script>

Reference

Properties

NameTypeDefaultDescriptionOptions
modelValueNumber1The current page number.
totalPagesNumberundefinedThe total number of pages.
pageSizeNumber10The number of items per page.
totalItemsNumber10The total number of items.
sizeString'sm'The size of the pagination buttons.'sm', 'md', 'lg'
sliceSizeNumber2The number of page buttons to show around the current page.
prevLabelString'Previous'The label for the previous button.
nextLabelString'Next'The label for the next button.
firstLabelString'First'The label for the first button.
lastLabelString'Last'The label for the last button.
showIconsBooleanfalseWhether to show icons for navigation buttons.
showFirstLastBooleanfalseWhether to show first and last page buttons.
hidePrevBooleanfalseWhether to hide the previous button.
hideNextBooleanfalseWhether to hide the next button.
hideLabelsBooleanfalseWhether to hide the labels for navigation buttons.
layoutString'pagination'The layout style of the pagination.'pagination', 'navigation', 'table'

Slots

NameDescription
startSlot for content at the beginning of the pagination.
first-buttonSlot for the first page button.
first-iconSlot for the icon of the first page button.
prev-buttonSlot for the previous page button.
prev-iconSlot for the icon of the previous page button.
page-buttonSlot for individual page number buttons.
next-buttonSlot for the next page button.
next-iconSlot for the icon of the next page button.
last-buttonSlot for the last page button.
last-iconSlot for the icon of the last page button.
endSlot for content at the end of the pagination.

Events

NameDescription
update:model-valueEmitted when the current page changes.
page-changedEmitted when the current page changes.

Released under the MIT License.