1.1.6 • Published 2 years ago

react-paginated-list v1.1.6

Weekly downloads
440
License
MIT
Repository
github
Last release
2 years ago

React Paginated List

npm npm NPM

A simple react component to render a paginated list ✨powered by styled-components 💅

DEMO

React Paginated List working

Installation

Using npm

npm install react-paginated-list

Or yarn

yarn install react-paginated-list

Usage

  • Pass in the list items that contain your data in the list prop
  • In the renderList prop, pass in the function to render out the list.
let users = [{'a': 123, 'b': 345}, {'c': 678, 'd': 891}];
return (
<PaginatedList
    list={users}
    itemsPerPage={3}
    renderList={(list) => (
      <>
        {list.map((item, id) => {
          return (
            <div key={id}>
              {item.a} {item.b}
            </div>
          );
        })}
      </>
    )}
  />);

Example Project

To run the example project,

  • Clone the repo
git clone https://github.com/rigelglen/react-paginated-list
  • Install deps
npm run install-all
  • Run example project
npm run dev

Props

* indicates a required prop

PropDescriptionTypeDefault
list*This is the list of items managed by the component. This list will be available in the renderList method to render your listArray-
renderList*This is the function that renders each of your list items.(list: Array) => JSX.Element-
itemsPerPageNumber of items per pagenumber10
onPageChangeCallback function that is called when the page is changed(items: Array, currentPage: number) => void-
isLoadingSets whether the list is loading or not.booleanfalse
ControlItemStyled Component for the pagination itemAnyStyledComponentstyled.li`
ControlContainerStyled Component for the pagination controlsAnyStyledComponentstyled.div
PaginatedListContainerStyled Component for the entire paginated list (contains the actual list and pagination controls)AnyStyledComponentstyled.div
loadingItemComponent to be displayed when list is loadingJSX.Element<p>Loading...</p>
breakTextText to be shown for ellipsisstring'...'
displayRangeThe range of pages displayednumber3
leftMarginNumber of extra pagination items to display on the leftnumber1
rightMarginNumber of extra pagination items to display on the rightnumber1
currentPageSets the initial pagenumber1
controlClassClass of the pagination boxstring'pagination'
activeControlClassClass of the active pagination itemstring'active'
displayNumbersDisplay pagination numbersbooleantrue
loopAroundLoop around after the endbooleanfalse
breakClassClass for the break itemstring'pagination-break'
nextClassClass of the next buttonstringnext
prevClassClass of the prev buttonstringprev
paginatedListContainerClassClass of the entire paginated list (contains the actual list and pagination controls)string-
controlItemClassClass of every pagination control itemstringpagination-item
showPrevShow previous pagination control (does nothing if useMinimalControls is true)booleantrue
showNextShow next pagination control (does nothing if useMinimalControls is true)booleantrue
nextTextText inside next buttonstring'〉'
prevTextText inside prev buttonstring'〈'
useMinimalControlsHides next or previous button if there is no next or previous page respectively.booleanfalse

LICENSE

Released under the MIT license. MIT: http://rem.mit-license.org, See LICENSE

1.1.6

2 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago