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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pagination-webcomponent

v4.0.4

Published

A lightweight, reusable, framework-agnostic pagination component built using Web Components (Custom Elements + Shadow DOM). Easily integrates into any HTML/JS app with no external dependencies.

Readme

🚀 Pagination UI <pagination-component>

A lightweight, reusable, framework-independent pagination component built using Web Components (Custom Elements + Shadow DOM). Easily integrates into any HTML/JS app with no external dependencies.

Pagination


Description

<pagination-component> is a lightweight, reusable Web Component that provides navigational pagination controls for paginated data views. It is framework-agnostic and can be used with any frontend stack including plain HTML/JS, React, Vue, Svelte, etc.

This component supports dynamic page ranges, ellipses for skipped blocks, and emits navigation events to allow integration with your data-fetching or UI update logic.

NPM Link


📦 Features

  • 🔌 Native Web Component (no framework needed)
  • 📐 Supports page ranges, previous/next, ellipsis
  • 💡 Emits a page-change event with all pagination info
  • 🎨 Styleable via CSS variables
  • ♻️ Reusable across frameworks (React, Vue, Svelte, etc.)
  • 🧠 Auto-handles large lists and intelligent rendering

Live Demo

🔗 CodePen: https://codepen.io/driftblaze/pen/gbaYvpG


Installation

Option 1: NPM Package

npm i pagination-webcomponent

then import as

import ('pagination-webcomponent')

Option 2: Unpkg

<script type="module" src="https://unpkg.com/pagination-webcomponent"></script>

Option 3: Module Import

import './PaginationComponent.js';

Option 4: HTML Script Tag

<script type="module" src="/path/to/PaginationComponent.js"></script>

Usage Example

<pagination-component
  offset="0"
  per-page="10"
  total="100"
></pagination-component>

<script>
  const pagination = document.querySelector('pagination-component');
  pagination.addEventListener('page-change', (e) => {
    console.log('New offset:', e.detail.offset);
    // Fetch data using e.detail.offset and e.detail.limit
  });
</script>

Attributes

| Attribute | Type | Required | Description | | ---------- | ------ | -------- | ----------------------------------------- | | offset | Number | ✅ | The current item offset (e.g., 0, 10, 20, ...). Clamped to valid bounds. | | per-page | Number | ✅ | Number of items per page | | total | Number | ✅ | Total number of items |

All attributes are reflected and can be dynamically updated.


Events

page-change

Dispatched whenever the user changes the page.

Payload

{
  "offset": Number,      // New offset (e.g., 30)
  "limit": Number,       // Items per page (e.g., 10)
  "total": Number,       // Total items (e.g., 100)
  "totalPages": Number   // Derived total pages (e.g., 10)
}

Styling

The component is styled via Shadow DOM and accepts the following CSS custom properties:

| CSS Variable | Description | |-------------------------------|------------------------------------| | --pagination-background | Button background | | --pagination-text | Button text color | | --pagination-border | Button border color | | --pagination-hover | Button hover and active background | | --pagination-active-border | Active page border highlight | | --pagination-active-color | Active button text color |

To override them:

pagination-component {
    --pagination-background: #181118;
    --pagination-text: #ecdfe8;
    --pagination-border: #9c8c9a;
    --pagination-hover: #91379f;
    --pagination-active-border: #ffcaff;
    --pagination-active-color: #ecdfe8;
}

Accessibility

  • Uses native <button> elements
  • Includes appropriate disabled states
  • Fully keyboard navigable

License

MIT License © 2025

Maintainer

This component is maintained by Yash Raj Bharti.