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 🙏

© 2024 – Pkg Stats / Ryan Hefner

pagination-ts-js

v1.1.2

Published

pagination-ts-js is a lightweight pagination component designed for React and Next.js, with TypeScript support. Easily integrate and customize pagination for efficient navigation of large datasets. No additional dependencies required. Simplify pagination

Downloads

13

Readme

Pagination Component - pagination-ts-js

The pagination-ts-js package is a versatile pagination component for React projects. It offers easy implementation of pagination with features like setting total pages, tracking the current page, and customization options for styling buttons. It's designed to simplify pagination integration while allowing for seamless customization to match your project's design.

Features

  • TypeScript Support: Ensures type safety and improved development experience.
  • Customization Options: Easily customize styles, button appearance, and add icons for a tailored pagination component.
  • Easy Integration: Simple API for seamless integration into React and Next.js projects.
  • Total Page Control: Set the total number of pages to accommodate different datasets.
  • Current Page Tracking: Tracks the active page for smooth navigation.
  • Handle Page Change: Provides a callback function to manage page transitions effortlessly.
  • Next.js Compatibility: Compatible with Next.js projects for server-side rendering and static generation.
  • Responsive Design: Adapts to various screen sizes for a consistent user experience.
  • Accessibility: Prioritizes accessibility standards for inclusivity.
  • Extendable: Easily extend functionality or add features as needed.
  • Documentation and Support: Comprehensive documentation and community support for effective usage.

These features make pagination-ts-js a valuable tool for implementing pagination in React and Next.js projects, offering flexibility, ease of use, and a seamless user experience.

Installation

To install the Pagination component, you can use npm or yarn:

npm install pagination-ts-js

Or

yarn add pagination-ts-js

Example

import { Pagination } from "pagination-ts-js";
import  { useState } from "react";

const App = () => {
  const [currentPage, setCurrentPage] = useState(1);

  return (
     <Pagination
        totalPage={10}
        currentPage={currentPage}
        handlePageChange={setCurrentPage}
        customStyle=""
        buttonOptions={{
          buttonStyle: "",
          preButton: {
            btnText: "Pre", //default text is "Previous"
           icon: "", //svg component
            textHide: false, // true to hide text
          },
          nextButton: {
            btnText: "Next", //default text is "Next"
            icon: "", //svg component
            textHide: false, // true to hide text
          },
        }}
      />
  );
};

export default App;

Props

The Pagination component accepts the following props:

| Name | Type | Description | Default Value | | ------------------ | -------- | ------------------------------------------------------------------------------ | ------------------- | | totalPage | number | Total number of pages. | - | | currentPage | number | Current active page. | - | | handlePageChange | function | Function to handle page change. Accepts a function that sets the current page. | - | | customStyle | string | Custom CSS styles for the pagination component. | Empty string ("") | | buttonOptions | object | Object containing options for customization of buttons. See below for details. | - |

buttonOptions

| Name | Type | Description | Default Value | | ------------- | ------ | ------------------------------------------------------- | ------------- | | buttonStyle | string | CSS class for styling the buttons. | - | | preButton | object | Options for the previous button. See below for details. | - | | nextButton | object | Options for the next button. See below for details. | - |

preButton and nextButton Options

| Name | Type | Description | Default Value | | ---------- | ------- | --------------------------------------------- | ----------------------------------------------- | | btnText | string | Text to be displayed on the button. | "Previous" for preButton, "Next" for nextButton | | icon | element | Icon component to be displayed on the button. | - | | textHide | boolean | Determines whether to hide the button text. | false |