Skip to content
Harness Design System Harness Design System Harness Design System

Pagination

beta

The Pagination component allows navigation through pages of content. It supports displaying a range of page numbers, as well as “Previous” and “Next” buttons.

There are two types of pagination:

  • Determinate
  • Indeterminate

The totalItems and pageSize props are used to determine the total number of items and the number of items per page in the pagination. If totalItems and pageSize are provided, the component will display the page numbers along with the navigation buttons. If totalItems and pageSize are not provided, the component will only display the “Next” and “Previous” buttons.

Determinate Pagination (Button)

Determinate Pagination with Hidden Page Numbers

Indeterminate Pagination with Callbacks

Usage

Determinate Pagination

import { Pagination } from '@harnessio/ui/components'
//...
const [currentPage, setCurrentPage] = useState(1)
const { t } = useTranslationStore()
return (
<Pagination
totalItems={100}
pageSize={10}
currentPage={currentPage}
goToPage={setCurrentPage}
t={t}
/>
)

Indeterminate Pagination

import { Pagination } from '@harnessio/ui/components'
//...
const [currentPage, setCurrentPage] = useState(1)
const { t } = useTranslationStore()
return (
<Pagination
indeterminate
hasPrevious={currentPage > 1}
hasNext={currentPage < 100}
// if need to use links
getPrevPageLink={() => currentPage - 1}
getNextPageLink={() => currentPage + 1}
// if need to use buttons
onPrevious={() => setCurrentPage(currentPage - 1)}
onNext={() => setCurrentPage(currentPage + 1)}
t={t}
/>
)
PropRequiredDefaultType
ttrueTFunction
classNamefalsestring
indeterminatefalsefalseboolean
totalItemsfalsenumber
pageSizefalsenumber
currentPagefalsenumber
hidePageNumbersfalsefalseboolean
goToPagefalse(page: number) => void
getPageLinkfalse(page: number) => string
hasPreviousfalseboolean
hasNextfalseboolean
onPreviousfalse() => void
onNextfalse() => void
getPrevPageLinkfalse() => string
getNextPageLinkfalse() => string