Socket
Book a DemoInstallSign in
Socket

pagination-webcomponent

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pagination-webcomponent

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.

4.0.4
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

🚀 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

AttributeTypeRequiredDescription
offsetNumberThe current item offset (e.g., 0, 10, 20, ...). Clamped to valid bounds.
per-pageNumberNumber of items per page
totalNumberTotal 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 VariableDescription
--pagination-backgroundButton background
--pagination-textButton text color
--pagination-borderButton border color
--pagination-hoverButton hover and active background
--pagination-active-borderActive page border highlight
--pagination-active-colorActive 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.

Keywords

pagination

FAQs

Package last updated on 13 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.