Pagination
Help users navigate collections of numbered pages like search results.
Read the Design System guidance for pagination
Import
import * as Pagination from 'govuk-react/pagination';Examples
Default
Code
<Pagination.Composite
previousHref="#"
nextHref="#"
>
{(
<>
<Pagination.ItemComposite href="#" number={1} />
<Pagination.ItemComposite href="#" number={2} current />
<Pagination.ItemComposite href="#" number={3} />
</>
)}
</Pagination.Composite>With ellipsis
Code
<Pagination.Composite
previousHref="#"
nextHref="#"
>
{(
<>
<Pagination.ItemComposite href="#" number={1} />
<Pagination.ItemComposite ellipsis />
<Pagination.ItemComposite href="#" number={6} />
<Pagination.ItemComposite href="#" number={7} current />
<Pagination.ItemComposite href="#" number={8} />
<Pagination.ItemComposite ellipsis />
<Pagination.ItemComposite href="#" number={42} />
</>
)}
</Pagination.Composite>First page
Code
<Pagination.Composite nextHref="#">
{(
<>
<Pagination.ItemComposite href="#" number={1} current />
<Pagination.ItemComposite href="#" number={2} />
<Pagination.ItemComposite href="#" number={3} />
</>
)}
</Pagination.Composite>Last page
Code
<Pagination.Composite previousHref="#">
{(
<>
<Pagination.ItemComposite href="#" number={1} />
<Pagination.ItemComposite href="#" number={2} />
<Pagination.ItemComposite href="#" number={3} current />
</>
)}
</Pagination.Composite>For navigating between related pages
Code
<Pagination.Composite
previousHref="#"
previousText="Previous page"
previousLabel="Applying for a provisional lorry or bus licence"
nextHref="#"
nextText="Next page"
nextLabel="Driver CPC part 1 test: theory"
/>With react router
Code
<MemoryRouter>
<Pagination.Root>
<Pagination.Previous>
<Pagination.PreviousLink asChild>
<RouterLink to="/page-1">
<Pagination.PreviousIcon /> <Pagination.PreviousLinkTitleComposite />
</RouterLink>
</Pagination.PreviousLink>
</Pagination.Previous>
<Pagination.List>
<Pagination.Item>
<Pagination.ItemLink asChild aria-label="Page 1">
<RouterLink to="/page-1">1</RouterLink>
</Pagination.ItemLink>
</Pagination.Item>
<Pagination.Item current>
<Pagination.ItemLink asChild aria-label="Page 2" aria-current="page">
<RouterLink to="/page-2">2</RouterLink>
</Pagination.ItemLink>
</Pagination.Item>
<Pagination.Item>
<Pagination.ItemLink asChild aria-label="Page 3">
<RouterLink to="/page-3">3</RouterLink>
</Pagination.ItemLink>
</Pagination.Item>
</Pagination.List>
<Pagination.Next>
<Pagination.NextLink asChild>
<RouterLink to="/page-3">
<Pagination.NextLinkTitleComposite /> <Pagination.NextIcon />
</RouterLink>
</Pagination.NextLink>
</Pagination.Next>
</Pagination.Root>
</MemoryRouter>API reference
Pagination.Root
Help users navigate collections of numbered pages like search results.
| Prop | Type |
|---|---|
block | boolean |
Pagination.Composite
Help users navigate collections of numbered pages like search results.
| Prop | Type |
|---|---|
previousHrefThe previous page's URL. | string |
previousTextThe text content of the link to the previous page. Defaults to | ReactNode |
previousLabelThe optional label that goes underneath the link to the previous page, providing further context for the user about where the link goes. | ReactNode |
nextHrefThe next page's URL. | string |
nextTextThe text content of the link to the next page. Defaults to | ReactNode |
nextLabelThe optional label that goes underneath the link to the next page, providing further context for the user about where the link goes. | ReactNode |
itemsPrefer children, which memoise and re-render better. | ItemCompositeProps[] |
Pagination.Item
| Prop | Type |
|---|---|
current | boolean |
ellipsis | boolean |
Pagination.ItemComposite
| Prop | Type |
|---|---|
asChildRender the only child (such as a router's link) instead of an | boolean |
numberThe pagination item text – usually a page number. Required unless the item is an ellipsis. | string | number |
currentSet to | boolean |
ellipsisUse this option if you want to specify an ellipsis at a given point between numbers. If you set this option as | boolean |
Pagination.ItemLink
| Prop | Type |
|---|---|
asChildRender the only child (such as a router's link) instead of an | boolean |
Pagination.Link
| Prop | Type |
|---|---|
asChildRender the only child (such as a router's link) instead of an | boolean |
Pagination.LinkLabel
No props of its own. Other props are passed to the element it renders.
Pagination.LinkTitle
| Prop | Type |
|---|---|
decorated | boolean |
Pagination.List
No props of its own. Other props are passed to the element it renders.
Pagination.Next
No props of its own. Other props are passed to the element it renders.
Pagination.NextIcon
No props of its own. Other props are passed to the element it renders.
Pagination.NextLink
| Prop | Type |
|---|---|
asChildRender the only child (such as a router's link) instead of an | boolean |
Pagination.NextLinkTitleComposite
| Prop | Type |
|---|---|
decorated | boolean |
Pagination.Previous
No props of its own. Other props are passed to the element it renders.
Pagination.PreviousIcon
No props of its own. Other props are passed to the element it renders.
Pagination.PreviousLink
| Prop | Type |
|---|---|
asChildRender the only child (such as a router's link) instead of an | boolean |
Pagination.PreviousLinkTitleComposite
| Prop | Type |
|---|---|
decorated | boolean |