Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chakra-paginator

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chakra-paginator

## Version

  • 0.2.1
  • npm
  • Socket score

Version published
Weekly downloads
535
increased by24.42%
Maintainers
1
Weekly downloads
 
Created
Source

Chakra paginator

Version

npm version

Installation

npm

npm i chakra-paginator

Yarn

yarn add chakra-paginator

Demo

Check it out in this Sandbox

Usage

import { ButtonProps } from "@chakra-ui/react";
import {
  Paginator,
  Previous,
  Page,
  Next,
  PageGroup,
  generatePages,
} from "chakra-paginator";

const Component = () => {
  // Calculated or obtained from Backend
  const pagesQuantity = 6;

  // styles
  const normalStyles: ButtonProps = {
    color: "green.300",
    bg: "red.300",
  };

  const activeStyles: ButtonProps = {
    color: "red.300",
    bg: "green.300",
  };

  // handlers
  const handlePageChange = (page: number) => {
    // Request new data using the page number
  };

  return (
    <Paginator
      isDisabled={isPaginatorDisabled}
      onPageChange={handlePageChange}
      pagesQuantity={pagesQuantity}
    >
      <Previous>
        Previous
        {/* i.e. an icon from `react-icons` */}
      </Previous>
      <PageGroup>
        {generatePages(pagesQuantity)?.map((page: number) => (
          <Page
            key={`paginator_page_${page}`}
            activeStyles={activeStyles}
            normalStyles={normalStyles}
            page={page}
          />
        ))}
      </PageGroup>
      <Next>
        Next
        {/* i.e. an icon from `react-icons` */}
      </Next>
    </Paginator>
  );
};

Components API

Paginator

PropDescriptionTypeDefaultRequired
pagesQuantityThe total number of pages, calculated based on Backend datanumber0yes
isDisabledDisables all of the pagination components. You can always disable each individual component via the isDisabled prop, as the components render HTML buttonsbooleanfalseno
onPageChangeOn change handler which returns the last selected page(currentPage: number) => void-yes

Page

PropDescriptionTypeDefaultRequired
keyThis is not strictly related to the library but never forget to pass it down to the componentstring-yes
activeStylesThe styles of the active page buttonButtonProps-no
normalStylesThe styles of the inactive page buttonsButtonProps-no
pageNumber used internally which is returned on the onPageChange handler when selecting the page

For now use the generatePages helper with which you shouldn't have any problems. This may change in the future
number-yes

Keywords

FAQs

Package last updated on 07 Jan 2021

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc