Socket
Book a DemoInstallSign in
Socket

@bolttech/molecules-pagination

Package Overview
Dependencies
Maintainers
7
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bolttech/molecules-pagination

The **Pagination** component is a customizable React component that provides navigation between different pages of content.

0.21.1
latest
npmnpm
Version published
Weekly downloads
168
-7.69%
Maintainers
7
Weekly downloads
 
Created
Source

Pagination Component

The Pagination component is a customizable React component that provides navigation between different pages of content.

Installation

To use the Pagination component, you need to install the required dependencies:

npm install @bolttech/frontend-foundations @bolttech/molecules-pagination

or

yarn add @bolttech/frontend-foundations @bolttech/molecules-pagination

Usage

You can utilize the Pagination component by importing it and including it in your JSX. Here's an example:

import React, {useState} from 'react';
import {Pagination} from '@bolttech/molecules-pagination';
import {bolttechTheme, BolttechThemeProvider} from "@bolttech/frontend-foundations"; // Adjust the path to your component

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

  const handlePageChange = (newPage) => {
    setCurrentPage(newPage);
  };

  return (
    <BolttechThemeProvider theme={bolttechTheme}>
      {/* Content */}
      {/* Pagination component */}
      <Pagination
        current={currentPage}
        pages={10}
        onChange={handlePageChange}
        texts={{
          previous: 'Previous',
          next: 'Next',
          current: 'Page $current of $pages',
        }}
      />
    </BolttechThemeProvider>
  );
}

export default App;

Props

The Pagination component accepts the following props:

PropTypeDescription
currentnumberThe current active page number.
dataTestIdstringThe data-testid attribute for testing purposes.
idstringThe ID attribute for the component.
onChangefunctionCallback function triggered when page changes.
pagesnumberThe total number of pages.
textsobjectObject containing text labels for the pagination.

The texts prop is an object with the following properties:

  • previous: Text for the previous page button.
  • next: Text for the next page button.
  • current: Text for displaying the current page and total pages. You can use $current and $pages placeholders in the text, which will be replaced with the actual values.

Functionality

The Pagination component provides the following functionality:

  • Navigation: Renders navigation buttons for the previous and next pages.
  • Page Selection: Displays a dropdown allowing the user to select a specific page.
  • Text Customization: Allows customization of the text labels and placeholders.
  • Disabled Buttons: Disables the previous button on the first page and the next button on the last page.

Contribution

Contributions to the Pagination component are welcomed. If you encounter issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the component's Bitbucket repository.

FAQs

Package last updated on 20 Nov 2024

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.