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

react-pagination-kit

v1.2.2

Published

A customizable pagination component for React

Downloads

29

Readme

react-pagination-kit

A customizable pagination component for React.

Table of Contents


Description

react-pagination-kit is a lightweight, customizable pagination component for React that allows developers to efficiently implement paginated navigation for large datasets.

  • Simple to use and easy to integrate.
  • Fully customizable via props, including custom "Next" and "Previous" buttons.
  • Option for dynamically changing the number of items per page.
  • Can accept custom CSS classes and styles.
  • No external dependencies.

Features

  • Customizable Pagination Controls: Supports text, icons, or HTML for "Next" and "Previous" buttons.
  • Responsive Design: Adjusts based on the number of items per page and total pages.
  • Custom Styling: You can override default styles with your own classes or inline styles.
  • Dropdown for Items per Page: Allows users to select how many items they want to see per page.
  • No Dependencies: The component is lightweight and only relies on React.

Installation

You can install react-pagination-kit using npm:

npm install react-pagination-kit

## Usage

You can import and use the `Pagination` component in your React project like this:

### Example

```jsx
import React, { useState } from 'react';
import Pagination from 'react-pagination-kit';

const App = () => {
  const [currentPage, setCurrentPage] = useState(1);
  const [itemsPerPage, setItemsPerPage] = useState(5);
  const totalPages = 10; // Total number of pages

  // Handle page change
  const handlePageChange = (page) => {
    setCurrentPage(page);
  };

  // Handle items per page change
  const handleItemsPerPageChange = (items) => {
    setItemsPerPage(items);
  };

  return (
    <div>
      <h1>Pagination Example</h1>

      {/* Your data display here */}
      <p>Showing page {currentPage} of {totalPages} pages</p>

      {/* Pagination component */}
      <Pagination
        totalPages={totalPages}
        currentPage={currentPage}
        onPageChange={handlePageChange}
        itemsPerPage={itemsPerPage}
        onItemsPerPageChange={handleItemsPerPageChange}
        itemsPerPageOptions={[5, 10, 15]}  // Options for items per page
      />
    </div>
  );
};

export default App;


### Component Props

| Prop                        | Type                            | Description                                                                                       |
| --------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------- |
| `totalPages`                 | `number`                        | Total number of pages to display.                                                                 |
| `currentPage`                | `number`                        | The current page number.                                                                           |
| `onPageChange`               | `function`                      | Callback function triggered when a page is selected. Receives the new page number as an argument. |
| `itemsPerPageOptions`        | `array[number]`                 | Array of options for the number of items per page. Defaults to `[5, 10, 15]`.                      |
| `itemsPerPage`               | `number`                        | The number of items per page.                                                                     |
| `onItemsPerPageChange`       | `function`                      | Callback function triggered when items per page is changed. Receives the new number of items as an argument. |
| `customClasses`              | `object`                        | Custom class names for different parts of the pagination component.                             |
| `customStyles`               | `object`                        | Custom inline styles for different parts of the pagination component.                            |
| `nextText`                   | `string` or `node`              | Custom text or component to render for the next button. Defaults to `"Next"`.                     |
| `previousText`               | `string` or `node`              | Custom text or component to render for the previous button. Defaults to `"Previous"`.             |
| `showPaginationControls`     | `boolean`                       | Boolean to show/hide pagination controls. Defaults to `true`.                                     |

### Example of Customization

You can customize the appearance of the pagination component using the `customClasses` and `customStyles` props.

```jsx
<Pagination
  totalPages={10}
  currentPage={1}
  onPageChange={(page) => console.log(page)}
  itemsPerPage={5}
  onItemsPerPageChange={(items) => console.log(items)}
  customClasses={{
    container: "my-custom-container",
    pagination: "my-custom-pagination",
    prevButton: "my-custom-prev-button",
    nextButton: "my-custom-next-button",
  }}
  customStyles={{
    container: { padding: "20px", backgroundColor: "#f0f0f0" },
    prevButton: { backgroundColor: "#ccc", color: "#333" },
    nextButton: { backgroundColor: "#ccc", color: "#333" },
  }}
/>