2.10.3 • Published 3 months ago

react-responsive-pagination v2.10.3

Weekly downloads
127
License
MIT
Repository
github
Last release
3 months ago

React Responsive Pagination

npm version minzipped size GitHub license Test Release semantic-release

An accessible responsive React pagination component which intelligently renders to the available width - for React 19, 18, 17 & 16

✅ Fully accessible with aria tags for screen readers
✅ Ready styled themes (or bring your own css)
✅ Bootstrap 4 & 5 support built-in
✅ Built for tree-shaking = minimum impact on the bundle

⚡️ LIVE DEMO - try it out for yourself! ⚡️

⭐️ What's new: React 19 support

📕 Visit https://react-responsive-pagination.elantha.com to get started 🚀

v1 user? See the v1 migration guide to start using v2

⏳ Quick Start

npm install react-responsive-pagination
import React, { useState } from 'react';
import ResponsivePagination from 'react-responsive-pagination';
import 'react-responsive-pagination/themes/classic.css';
// 👆 classic theme, see below for other theme / css options

function MyApp() {
  const [currentPage, setCurrentPage] = useState(8);
  const totalPages = 20;

  return (
    <ResponsivePagination
      current={currentPage}
      total={totalPages}
      onPageChange={setCurrentPage}
    />
  );
}

Three ways to style:

  1. 🎨 Custom styling

    Custom styles? No problem - see the Custom Styles Guide

  2. 🖼️ Ready-to-go themes (NEW!)

    Just import one of the css themes into your project (as shown in the quickstart example above)

    import 'react-responsive-pagination/themes/classic.css';
    ThemeExample
    classic.css
    bootstrap.cssBootstrap 5 styled pagination (without installing Bootstrap)See additional bootstrap options
    minimal.css

    Please see the Themes guide for more details (including overridable theme attributes)

    Want to create your own? See the Custom Styles Guide

  3. 🥾 Bootstrap 4 and 5

    Using Bootstrap in your project? react-responsive-pagination just works with Bootstrap (no need for any additional styles). See the Bootstrap Getting Started Guide

✔︎ Requirements / Compatibility

  • React 19, 18, 17 and 16.8 upwards
  • Modern browsers only - not suitable for IE 11

🔧 Props

Common Props

PropDescription
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

ClassName Props

See Overriding default classNames for more information

PropDescription
classNamestring(optional)Class name for the top level <ul> containerDefaults 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-startDefaults to justify-content-center, not applicable if className prop (above) is set
pageItemClassNamestring(optional)Class name for all the <li> elementsDefaults 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
navClassNamestring(optional)Appended to \ class name for nav items (« / » buttons):<li class='page-item my-nav'><span class='page-link'>«</span></li>By defaults is not output
previousClassNamestring(optional)Appended to \ class name for the nav previous button («):<li class='page-item my-previous-button'><span class='page-link'>«</span></li>By defaults is not output
nextClassNamestring(optional)Appended to \ class name for the nav next button (»):<li class='page-item my-next-button'><span class='page-link'>»</span></li>By defaults is not output

Label Props

PropDescription
previousLabelstring \| ReactNode(optional)The label for the previous button, defaults to «See the FAQ for further information on using React components for this prop
nextLabelstring \| ReactNode(optional)The label for the next button, defaults to » See the FAQ for further information on using React components for this prop
ariaPreviousLabelstring(optional)The accessibility ARIA label for the previous button, defaults to Previous
ariaNextLabelstring(optional)The accessibility ARIA label for the next button, defaults to Next

Misc Props

PropDescription
renderNavboolean(optional)When set to false the nav buttons («/») will not be rendered. Defaults to true
narrowBehaviourNarrowBehaviour(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)Valid behaviours should be imported from react-responsive-pagination/narrowBehaviour, see exampledropEllipsis - drop the ellipsis () for narrow widthsdropNav - drop the nav («/») for narrow widthsdropFirstAndLast - drop the first and last pages for narrow widthsUse the combine helper to combine narrowBehaviours, example:narrowBehaviour={combine(dropNav, dropEllipsis)} - drop the nav initially and then further drop the ellipsis if requiredcombine should also be imported from react-responsive-pagination/narrowBehaviour see examples

See Props Reference for the full list

ℹ About Auto Sizing

More info in the FAQ

2.9.1

6 months ago

2.10.1

4 months ago

2.10.2

4 months ago

2.10.0

5 months ago

2.10.3

3 months ago

2.10.3-beta.1

3 months ago

2.10.2-beta.1

4 months ago

2.10.0-beta.1

6 months ago

2.9.1-beta.1

6 months ago

2.8.0-beta.1

9 months ago

2.8.0

9 months ago

2.7.1

9 months ago

2.9.0

8 months ago

2.6.1-beta.1

12 months ago

2.7.0

10 months ago

2.7.1-beta.1

10 months ago

2.7.0-beta.1

11 months ago

2.7.0-beta.2

11 months ago

2.6.1

11 months ago

2.6.0

12 months ago

2.6.0-beta.5

1 year ago

2.6.0-beta.3

1 year ago

2.6.0-beta.4

1 year ago

2.6.0-beta.1

1 year ago

2.6.0-beta.2

1 year ago

2.5.0

1 year ago

2.5.0-beta.3

1 year ago

2.4.4

1 year ago

2.5.0-beta.1

1 year ago

2.5.0-beta.2

1 year ago

2.4.4-beta.2

1 year ago

2.4.4-beta.1

1 year ago

2.4.3

1 year ago

2.4.3-beta.1

1 year ago

2.4.2

1 year ago

2.4.2-beta.1

1 year ago

2.4.1

1 year ago

2.4.1-beta.1

1 year ago

2.4.0

1 year ago

2.4.0-beta.1

1 year ago

2.3.0-beta.1

2 years ago

2.3.0

2 years ago

2.2.4

2 years ago

2.2.4-beta.1

2 years ago

2.2.3-beta.1

2 years ago

2.2.2-beta.2

2 years ago

2.2.2-beta.1

2 years ago

2.2.1

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.2.1-beta.1

2 years ago

1.10.2

2 years ago

2.2.0-beta.1

2 years ago

2.2.0-beta.2

2 years ago

2.2.0-beta.3

2 years ago

2.2.0-beta.4

2 years ago

2.2.0-beta.5

2 years ago

2.2.0-beta.6

2 years ago

2.2.0-beta.7

2 years ago

2.2.0

2 years ago

1.10.1-beta.1

2 years ago

2.0.1-beta.1

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

2.0.0-beta.9

2 years ago

2.0.0-beta.8

2 years ago

2.0.0-beta.7

2 years ago

1.10.2-beta.1

2 years ago

2.0.0-beta.2

2 years ago

2.0.0-beta.1

2 years ago

2.0.0-beta.6

2 years ago

2.0.0-beta.5

2 years ago

2.1.0

2 years ago

2.0.0-beta.4

2 years ago

2.0.0-beta.3

2 years ago

2.1.0-beta.1

2 years ago

1.10.1

2 years ago

1.8.1

3 years ago

1.9.0

3 years ago

1.10.0-beta.4

3 years ago

1.10.0-beta.3

3 years ago

1.10.0-beta.2

3 years ago

1.10.0-beta.1

3 years ago

1.8.1-beta.1

3 years ago

1.8.1-beta.2

3 years ago

1.9.0-beta.1

3 years ago

1.10.0

3 years ago

1.7.0-beta.1

3 years ago

1.8.0

3 years ago

1.8.0-beta.1

3 years ago

1.7.0

3 years ago

1.6.0

3 years ago

1.5.0

3 years ago

1.5.0-beta.1

3 years ago

1.6.0-beta.1

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.4.0-beta.1

3 years ago

1.4.1-beta.1

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.3-beta.1

3 years ago

1.3.1

3 years ago

1.3.2-beta.1

3 years ago

1.3.1-beta.1

4 years ago

1.3.1-beta.2

3 years ago

1.3.0

4 years ago

1.3.0-beta.1

4 years ago

1.2.0

4 years ago

1.2.0-beta.2

4 years ago

1.1.9

4 years ago

1.1.9-beta.1

4 years ago

1.1.8

4 years ago

1.1.8-beta.1

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.5-beta.3

4 years ago

1.1.4

4 years ago

1.1.5-beta.1

4 years ago

1.1.4-beta.1

4 years ago

1.1.5-beta.2

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.2-beta.2

4 years ago

1.1.2-beta.1

4 years ago

1.2.0-beta.1

4 years ago

1.1.1

5 years ago

1.1.1-beta.1

5 years ago

1.1.0

5 years ago

1.1.0-beta.1

5 years ago

1.0.3

5 years ago

1.0.3-beta.1

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.1-beta.1

5 years ago

1.0.0

5 years ago

1.0.0-beta.1

5 years ago

0.1.1

6 years ago

0.1.0

6 years ago