No Preview

Sorry, but you either have no stories or none are selected somehow.

If the problem persists, check the browser console, or the terminal you've run Storybook from.

Material Pagination Component

React Data Table already has a "Material" looking Pagination, but if you want to go a step further you can integration Material UI's Pagination component.

Using the paginationComponent property is you can access React Data Tables internal pagination properties.

({ rowsPerPage, rowCount, onChangePage, onChangeRowsPerPage, currentPage }) => ...

Import and Create our Material UI Pagination Component

import React from 'react'; import TablePagination from '@material-ui/core/TablePagination'; import IconButton from '@material-ui/core/IconButton'; import FirstPageIcon from '@material-ui/icons/FirstPage'; import KeyboardArrowLeft from '@material-ui/icons/KeyboardArrowLeft'; import KeyboardArrowRight from '@material-ui/icons/KeyboardArrowRight'; import LastPageIcon from '@material-ui/icons/LastPage'; function TablePaginationActions({ count, page, rowsPerPage, onChangePage }) { const handleFirstPageButtonClick = () => { onChangePage(1); }; // RDT uses page index starting at 1, MUI starts at 0 // i.e. page prop will be off by one here const handleBackButtonClick = () => { onChangePage(page); }; const handleNextButtonClick = () => { onChangePage(page + 2); }; const handleLastPageButtonClick = () => { onChangePage(getNumberOfPages(count, rowsPerPage)); }; return ( <> <IconButton onClick={handleFirstPageButtonClick} disabled={page === 0} aria-label="first page"> <FirstPageIcon /> </IconButton> <IconButton onClick={handleBackButtonClick} disabled={page === 0} aria-label="previous page"> <KeyboardArrowLeft /> </IconButton> <IconButton onClick={handleNextButtonClick} disabled={page >= getNumberOfPages(count, rowsPerPage) - 1} aria-label="next page" > <KeyboardArrowRight /> </IconButton> <IconButton onClick={handleLastPageButtonClick} disabled={page >= getNumberOfPages(count, rowsPerPage) - 1} aria-label="last page" > <LastPageIcon /> </IconButton> </> ); } const CustomMaterialPagination = ({ rowsPerPage, rowCount, onChangePage, onChangeRowsPerPage, currentPage }) => ( <TablePagination component="nav" count={rowCount} rowsPerPage={rowsPerPage} page={currentPage - 1} onChangePage={onChangePage} onChangeRowsPerPage={({ target }) => onChangeRowsPerPage(Number(target.value))} ActionsComponent={TablePaginationActions} /> ); export default CustomMaterialPagination'

You can now pass CustomMaterialPagination to paginationComponent

... <DataTable columns={columns} data={data} pagination paginationComponent={CustomMaterialPagination} /> ...
Movie List
Title
Director
Year
Beetlejuice
Tim Burton
1988
The Cotton Club
Francis Ford Coppola
1984
The Shawshank Redemption
Frank Darabont
1994
Crocodile Dundee
Peter Faiman
1986
Valkyrie
Bryan Singer
2008
Ratatouille
Brad Bird, Jan Pinkava
2007
City of God
Fernando Meirelles, Kátia Lund
2002
Memento
Christopher Nolan
2000
The Intouchables
Olivier Nakache, Eric Toledano
2011
Stardust
Matthew Vaughn
2007