shadcn.io is an independent project built on shadcn/ui
On this page9 sections
Pagination splits a long list across numbered pages and gives people the controls to move through them: previous and next, the page numbers, and an ellipsis where the run is cut short. When each page is a link, page 12 has an address that can be bookmarked, shared and crawled.
It sits under search results, a Table of orders or a blog archive. For the steps of a single task, such as a checkout, use Steps instead.
Installation
Anatomy

Usage
import {
Pagination, PaginationContent, PaginationEllipsis, PaginationItem,
PaginationLink, PaginationNext, PaginationPrevious,
} from "@/components/ui/pagination";Wrap each control in its own PaginationItem, and mark the page on screen with isActive.
<Pagination>
<PaginationContent>
<PaginationItem>
<PaginationPrevious href="?page=1" />
</PaginationItem>
<PaginationItem>
<PaginationLink href="?page=1">1</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationLink href="?page=2" isActive>
2
</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationLink href="?page=3">3</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationEllipsis />
</PaginationItem>
<PaginationItem>
<PaginationNext href="?page=3" />
</PaginationItem>
</PaginationContent>
</Pagination>Accessibility
Pagination renders a nav landmark labeled pagination, and each page is a link in the tab order. isActive on a PaginationLink sets aria-current="page", which a screen reader announces, and PaginationEllipsis is hidden from screen readers. With a pageCount and no getHref, the pages are buttons, the current one carries aria-current, and at either end Previous or Next gets aria-disabled and does nothing.
In a row of links, PaginationPrevious and PaginationNext are named Go to previous page and Go to next page whatever their text says, and below the sm breakpoint, where the words hide, that name is their only label. On a page in another language, pass each a translated aria-label.
Demos
Simple
Five numbered links and nothing else, with page 2 marked by isActive, which outlines it and sets aria-current. A row of numbers suits a short run of five or six pages, where Previous and Next would only add width. Once the pages run past what fits, add Previous, Next and an ellipsis, as the preview at the top does.
Icons only
Previous and Next with no page numbers, beside a Rows per page select set to 25, as in the footer of a data table. Their words hide below the sm breakpoint, leaving only the arrows. Use it when the table already shows which rows are on screen, and keep the numbers when people need to jump far ahead.
RTL
The default row in Arabic, with dir set to rtl on Pagination, Arabic-Indic numerals and Arabic text on Previous and Next. The row starts at the right, and the arrows turn to point the way it reads. Those two are still named Go to previous page and Go to next page, so pass a translated aria-label alongside text.
FAQ
How do I track the current page with the UI SDK Pagination?
Either you or UI SDK can. Without a pageCount, this Pagination is a row of links: read the page from the URL, such as ?page=3, and set isActive on the PaginationLink that matches.
Give Pagination a pageCount or a total and UI SDK keeps the page instead, with each link that has a page following it and Previous and Next stepping it. Pass page and onPageChange to control it, and getHref to turn every part into a link, so a reload or a shared link lands on the same page.
How do I use Pagination with my router's Link component in React?
Pass your router's link element to render on PaginationLink. It receives the link's href, classes and aria-current, and Previous and Next take render the same way, so the whole row routes on the client. Keep an href on each one, or a getHref on a Pagination with a pageCount, so the pages stay crawlable.
How do I show an ellipsis when Pagination has many pages?
Give Pagination a pageCount and UI SDK works it out. siblings sets how many pages show on each side of the current one and boundaries how many at each end, 1 each by default, and a function child of PaginationContent receives the items to map: page numbers, with a string in each gap where a PaginationEllipsis goes. On page 10 of 20 that gives 1, an ellipsis, 9, 10, 11, an ellipsis and 20.
Why can I still click Previous on the first page?
Without a pageCount, Pagination is a row of links that doesn't know where it stands, so Previous stays live. Pass pageCount and UI SDK marks Previous aria-disabled on the first page and Next on the last, and pressing them does nothing.
In a row of links, set aria-disabled to true and tabIndex to -1 on PaginationPrevious while on page 1. The button styles then fade it and ignore clicks, and Tab skips it. Do the same for PaginationNext on the last page, or leave either one out.
How do I show only Previous and Next buttons in Pagination?
Keep PaginationPrevious and PaginationNext and leave the numbered links out, as the Icons only demo does beside a rows-per-page select. Below the sm breakpoint their words hide and only the arrows show.
Without numbers, people can't tell how far along they are, so show the range on screen next to the buttons, such as 26 to 50 of 312.
How do I change or translate the Pagination labels?
Pass text to PaginationPrevious and PaginationNext for the visible words, Previous and Next by default, as the RTL demo does in Arabic. That changes only what is seen. The name a screen reader reads stays Go to previous page and Go to next page until you pass a translated aria-label as well.
The landmark itself is named pagination, so give Pagination a translated aria-label too.
Should I use Pagination or infinite scroll?
Use pagination when people come back to a place in the list, compare items across pages or need what sits below the list: search results, an admin table, an archive. Each page has its own address, so the back button and a shared link land on the same items.
Infinite scroll suits a feed read once from the top. A Load more button sits between the two, keeping one address while letting people choose when to fetch more.
API Reference
Pagination
page?number
The current page, from 1. Pass it to control the pagination.
defaultPage?number
The page it starts on, when uncontrolled.
- Default
1
onPageChange?(page: number, details: ChangeDetails<PaginationPageChangeReason>) → void
Runs when the page wants to change: a page link ("item-press"), the Previous, Next, First or Last part, or a controller ("imperative"). details.cancel() keeps the page, and stops a link from navigating.
- Type
(page: number, details: ChangeDetails<PaginationPageChangeReason>) → void- Parameters
page– numberdetails– ChangeDetails<PaginationPageChangeReason>- Returns
void
boundaries?number
How many pages always show at each end.
- Default
1
controller?PaginationController
Pages it from anywhere. Create one with createPaginationController().
debug?boolean
Logs every state change with its reason to the console, in development builds.
disabled?boolean
Whether every page and step does nothing, like a step at its end. A controller still pages it.
- Default
false
getHref?(page: number) → string
The URL of a page. With it, parts are links: they navigate, open in a new tab with a modifier key, and work before JavaScript loads. Without it, they're buttons.
- Parameters
page– number- Returns
string
pageCount?number
How many pages there are. Or pass total and pageSize.
pageSize?number
How many items fit on a page, with total.
- Default
10
siblings?number
How many pages show on each side of the current one.
- Default
1
total?number
How many items there are, for pageCount from pageSize.
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
PaginationContent
<ul> data-slot="pagination-content"
children?React.ReactNode | ((state: PaginationState) → React.ReactNode)
Content, or a function of the pagination's page, pageCount and items.
- Type
React.ReactNode | ((state: PaginationState) → React.ReactNode)
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
PaginationItem
<li> data-slot="pagination-item"
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
PaginationLink
<a> data-slot="pagination-link"
isActive?boolean
Marks the link as the current page: outlined, and aria-current="page".
With a page, the pagination knows the current page itself.
page?number
The page it goes to, from 1, in a pagination with a pageCount. It
shows the number unless it has children.
render?ReactElement | ((props: object, state: object) => ReactElement)
Renders your own element, like a router's link, with the link's props.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
data-active?string
Mirrors isActive.
data-current?string
Present on the current page's link, beside aria-current="page".
PaginationPrevious
isActive?boolean
Marks the link as the current page: outlined, and aria-current="page".
With a page, the pagination knows the current page itself.
page?number
The page it goes to, from 1, in a pagination with a pageCount. It
shows the number unless it has children.
text?string
The button's label, beside its arrow.
- Default
"Previous"
render?ReactElement | ((props: object, state: object) => ReactElement)
Renders your own element, like a router's link, with the link's props.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
data-icon"inline-start"
- Default
"inline-start"
PaginationNext
isActive?boolean
Marks the link as the current page: outlined, and aria-current="page".
With a page, the pagination knows the current page itself.
page?number
The page it goes to, from 1, in a pagination with a pageCount. It
shows the number unless it has children.
text?string
The button's label, beside its arrow.
- Default
"Next"
render?ReactElement | ((props: object, state: object) => ReactElement)
Renders your own element, like a router's link, with the link's props.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
data-icon"inline-end"
- Default
"inline-end"
PaginationEllipsis
<span> data-slot="pagination-ellipsis"
className?string
Merged with the part's classes.











