1.2.6 • Published 7 months ago
react-pagination-kit v1.2.6
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" },
}}
/>
1.2.6
7 months ago
1.2.5
7 months ago
1.2.4
7 months ago
1.2.3
7 months ago
1.2.2
10 months ago
1.2.1
10 months ago
1.2.0
10 months ago
1.1.9
10 months ago
1.1.8
10 months ago
1.1.7
10 months ago
1.1.6
10 months ago
1.1.5
10 months ago
1.1.4
10 months ago
1.1.3
10 months ago
1.1.2
10 months ago
1.1.1
10 months ago
1.1.0
10 months ago
1.0.9
10 months ago
1.0.8
10 months ago
1.0.7
10 months ago
1.0.6
10 months ago
1.0.5
10 months ago
1.0.4
10 months ago
1.0.3
10 months ago
1.0.2
10 months ago
1.0.1
10 months ago
1.0.0
10 months ago