vue-ads-pagination is a Vue.js component designed to provide comprehensive pagination functionality for displaying large lists of items efficiently. It allows users to navigate through pages, showing information about the current item range (e.g., 'Items 1 to 10 of 100') and offering buttons for first, last, next, previous, and specific page selection. The current stable version, 2.1.7, is focused on Vue 2 compatibility. This package distinguishes itself by offering extensive customizability through slots, allowing developers to completely override default components (like the page buttons or item range display) with their own Vue components or apply custom styles to the default elements, making it highly adaptable to various UI designs. It provides distinct events for `page-change` and `range-change` to manage state updates effectively in the parent component. There's no explicit release cadence mentioned, but it acts as a mature, single-purpose component.
npm install vue-ads-paginationVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to integrate `VueAdsPagination` and `VueAdsPageButton` into a Vue component. It shows binding properties like `total-items`, `page`, and handling `page-change` and `range-change` events. The example also illustrates how to customize the display of item range information and individual pagination buttons using scoped slots.
When binding `page`, pass a value that is 0-based. If displaying to a user, increment the `page` value by 1.
Use an event listener like `@page-change="currentPage = $event"` or a method that updates your bound `page` data property.
Add `import 'vue-ads-pagination/dist/vue-ads-pagination.css';` to your main JavaScript/TypeScript file (e.g., `main.ts` or `main.js`) or within a `<style>` block in a root component.
Install `@fortawesome/fontawesome-free` and import its CSS (e.g., `import '@fortawesome/fontawesome-free/css/all.css';`) in your project, or override the 'buttons' slot with your custom button components that do not rely on Font Awesome.
Ensure `import VueAdsPagination from 'vue-ads-pagination';` is present in your script and `VueAdsPagination` is listed in the `components: {}` object of your Vue component.Add the `:total-items="yourTotalCount"` prop to the `<vue-ads-pagination>` component, ensuring its value is a number representing the total count of items.
Ensure your custom slot template uses `slot-scope="props"` (Vue 2) or `#default="props"` (Vue 2.6+ / Vue 3) to correctly destructure the scoped slot properties.