npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ziaqkh-pagination-vue-laravel

v1.0.4

Published

Reusable Vue pagination component for Laravel pagination.

Readme

Ziaqkh Vue Laravel Pagination

This component provides a responsive and easy-to-use pagination solution for your Vue.js applications, designed to work with standard Laravel pagination responses. It displays pagination links with "Previous" and "Next" navigation, as well as ellipses to shorten long page lists, showing only about 5 page links at a time around the current page.


Features

  • Full Navigation: Supports "Previous", "Next", and page number links.
  • Compact Display: Automatically displays ellipses (...) to shorten the list of pages, focusing on the current page and a few surrounding pages (maximum 5 page number links).
  • Responsive: Designed with Tailwind CSS for an adaptive layout across various screen sizes.
  • Accessibility: Includes descriptive aria-label attributes to enhance accessibility.
  • Easy Integration: Designed to accept a standard Laravel pagination object.

Installation

To use this component in your Vue.js project, install it via npm:

npm i ziaqkh-pagination-vue-laravel

After installation, import and use the component in your Vue files.

Prerequisites
This component relies on Tailwind CSS for its styling.
Please ensure that Tailwind CSS is properly installed and configured in your project before using this pagination component.


Usage

Props

This component accepts one prop:

  • pagination (Object, required):
    An object containing pagination information, structured like a standard Laravel pagination response (e.g., current_page, last_page, and links).

Example Pagination Object Structure

{
  "current_page": 1,
  "data": [],
  "first_page_url": "http://localhost?page=1",
  "from": 1,
  "last_page": 10,
  "last_page_url": "http://localhost?page=10",
  "links": [
    { "url": null, "label": "« Previous", "active": false },
    { "url": "http://localhost?page=1", "label": "1", "active": true },
    { "url": "http://localhost?page=2", "label": "2", "active": false },
    { "url": "http://localhost?page=3", "label": "3", "active": false },
    { "url": "http://localhost?page=4", "label": "4", "active": false },
    { "url": "http://localhost?page=5", "label": "5", "active": false },
    { "url": "http://localhost?page=6", "label": "6", "active": false },
    { "url": "http://localhost?page=7", "label": "7", "active": false },
    { "url": "http://localhost?page=8", "label": "8", "active": false },
    { "url": "http://localhost?page=9", "label": "9", "active": false },
    { "url": "http://localhost?page=10", "label": "10", "active": false },
    { "url": "http://localhost?page=2", "label": "Next »", "active": false }
  ],
  "next_page_url": "http://localhost?page=2",
  "path": "http://localhost",
  "per_page": 15,
  "prev_page_url": null,
  "to": 15,
  "total": 149
}

Emits

  • page-changed (number)
    Emitted when the user clicks a pagination link. The event payload is the new page number.

Example Implementation

<template>
  <div>
    <!-- Display your data here -->
    <div v-for="item in items" :key="item.id">
      {{ item.name }}
    </div>

    <!-- Pagination Component -->
    <Pagination :pagination="paginationData" @page-changed="handlePageChange" />
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import Pagination from './Pagination.vue'; // Adjust path if necessary

const items = ref([]);
const paginationData = ref({});

// Function to fetch data from the API
const fetchData = async (page = 1) => {
  try {
    const response = await fetch(`https://api.example.com/data?page=${page}`);
    const data = await response.json();

    items.value = data.data;
    paginationData.value = data;
  } catch (error) {
    console.error('Error fetching data:', error);
  }
};

// Handler when the page changes
const handlePageChange = (pageNumber) => {
  console.log('Changing page to:', pageNumber);
  fetchData(pageNumber);
};

// Fetch data when the component is first mounted
onMounted(() => {
  fetchData();
});
</script>

Styling

This component uses Tailwind CSS for styling.
Ensure Tailwind is correctly configured in your Vue project for the styles to apply properly.

You can customize the appearance by modifying the Tailwind classes within the component’s template or by adding custom styles in the <style scoped> section if needed.


Contributions

If you have suggestions or find bugs, feel free to open an issue or submit a pull request on the GitHub repository.