Skip to content

Pagination

Paginates a list by offset/limit, emitting load events when the user navigates pages.

bash
npm install @vuecs/pagination

Basic usage

vue
<script setup lang="ts">
import { VCPagination } from '@vuecs/pagination';
import { ref } from 'vue';

const meta = ref({ total: 100, offset: 0, limit: 10 });

const load = (next) => {
    meta.value.offset = next.offset;
    // refetch your data with the new offset
};
</script>

<template>
    <VCPagination
        :total="meta.total"
        :offset="meta.offset"
        :limit="meta.limit"
        @load="load"
    />
</template>
css
@import "tailwindcss";
@import "@vuecs/design";

/* Active-page + ellipsis structural CSS. */
@import "@vuecs/pagination";

@custom-variant dark (&:where(.dark, .dark *));

Props

PropTypeDefaultDescription
totalnumber0Total number of items
offsetnumber0Current offset
limitnumber0Items per page (must be > 0 for the component to render any pages)
busybooleanfalseDisable controls during loading
tagstring'ul'Root element tag
itemTagstring'li'Item wrapper tag

Events

EventPayloadDescription
load{ page, offset, limit, total } (PaginationMeta)Emitted when the user navigates pages. Note: the emitted total is the total page count (Math.ceil(items / limit)), not the input total items.

See also

Released under the Apache 2.0 License.