Skip to content

Pagination - Frameworks

Pagination is used to split up long datasets into multiple 'pages'.

Reactreleased

React

Import

You can import the component like so:

js
import { Pagination } from '@warp-ds/react';

or import it individually to optimize your JS bundle size by adding only the components you need:

js
import { Pagination } from '@warp-ds/react/components/pagination'

Props

Required props

NameTypeDefaultDescription
createHref(page: number) => stringFunction that returns the href for a given page
currentPagenumberThe current page number. Adjusted so its never below 1, and never above lastPage.
lastPagenumberThe number of the last page.

Optional Props

NameTypeDefaultDescription
classNamestringAdditional classes to include
styleCSSPropertiesCSS styles to inline on the component container.
onChange(page: number) => voidHandler that is called with the page number to navigate to. event.preventDefault is called for you. Fallbacks to default browser behavior if undefined.
numPagesnumberThe number of pages to show in the pagination.

Example

jsx
function PaginationExample() {
    const [currentPage, setCurrentPage] = useState(0);

    return <Pagination
        currentPage={currentPage}
        lastPage={10}
        createHref={(page) => `?page=${page}`}
        onChange={(page) => setCurrentPage(page)}
    />;
}

Questions?

Feel free to ask any questions on usage in the Warp DS Slack channel: #warp-design-system