Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
react-responsive-pagination
Advanced tools
A responsive React pagination component which intelligently renders to the available width - for React 16, 17 or 18
Using Bootstrap? See the Bootstrap Getting Started Guide
Custom styles? No problem - see the Custom Styles Guide
npm install react-responsive-pagination
(see below for a Bootstrap 5 example)
// ... make sure appropriate css is in the project (see guides above)
import React, { useState } from 'react';
import Pagination from 'react-responsive-pagination';
function MyApp() {
const [currentPage, setCurrentPage] = useState(4);
const totalPages = 17;
return (
<Pagination
current={currentPage}
total={totalPages}
onPageChange={setCurrentPage}
/>
);
}
import React, { useState } from 'react';
import Pagination, { bootstrap5PaginationPreset } from 'react-responsive-pagination';
function MyBootstrap5App() {
const [currentPage, setCurrentPage] = useState(4);
const totalPages = 17;
return (
<Pagination
{...bootstrap5PaginationPreset}
current={currentPage}
total={totalPages}
onPageChange={setCurrentPage}
/>
);
}
Prop | Description |
---|---|
currentnumber (required) | The current active page. Indexed from 1 |
totalnumber (required) | The total number of pages |
onPageChange(newPage: number) => void (required) | A callback handler which is called when the user clicks a new page, note that the active page will not change unless the current prop is updated to reflect the new page (as in the example above). The newPage value is indexed from 1 |
maxWidthnumber (optional) | The maximum width (in pixels) of the pagination component. Specify a value if you want to override the automatic sizing. Note this width may be exceeded in the case where it's not possible to output a small enough component |
See Overriding default classNames for more information
Prop | Description |
---|---|
classNamestring (optional) | Class name for the top level <ul> container Defaults to pagination , overrides extraClassName prop (below) |
extraClassNamestring (optional) | Useful when using Bootstrap styles, extra classNames to be added to the top level <ul> container. Use this prop to override the default justify value - for example to align elements to the start of the page use: justify-content-start Defaults to justify-content-center , not applicable if className prop (above) is set |
pageItemClassNamestring (optional) | Class name for all the <li> elements Defaults to page-item |
pageLinkClassNamestring (optional) | Class name for <a> or <span> child elements within an <li> element: <li ...><a class='page-link'>1</a></li> Defaults to page-link |
activeItemClassNamestring (optional) | Appended to <li> class name for the active element:<li class='page-item active'><a class='page-link'>1</a></li> Defaults to active |
disabledItemClassNamestring (optional) | Appended to <li> class name for non-clickable elements (disabled nav buttons and the break/ellipsis):<li class='page-item disabled'><span class='page-link'>...</span></li> Defaults to disabled |
srOnlyClassNamestring (optional) | Class for screen reader only content (which should be visually hidden) - see an example of typical css for this purpose Setting this prop to '' will turn off all the <span> based screen reader labels (however, aria-label attributes will still be output for screen readers)Defaults to sr-only |
Prop | Description |
---|---|
previousLabelstring (optional) | The label for the previous button, defaults to « |
nextLabelstring (optional) | The label for the next button, defaults to » |
Prop | Description |
---|---|
narrowStrategy'dropEllipsis' | 'dropNav' | ('dropEllipsis' | 'dropNav')[] (optional) | Specify that nav buttons («/») and/or the ellipsis (…) can be dropped for very narrow widths (useful if the component is used in narrow widths with high page numbers)'dropEllipsis' - drop the ellipsis (…) for narrow widths'dropNav' - drop the nav («/») for narrow widths['dropNav', 'dropEllipsis'] - drop the nav initially and then further drop the ellipsis if required['dropEllipsis', 'dropNav'] - drop the ellipsis initially and then further drop the nav if required |
See Props Reference for the full list
More info in the FAQ
FAQs
React component for responsive pagination
The npm package react-responsive-pagination receives a total of 3,188 weekly downloads. As such, react-responsive-pagination popularity was classified as popular.
We found that react-responsive-pagination demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.