Pagination
Page navigation that keeps every button in place, glides to the current page and jumps to any page from the ellipsis.
- Navigation components
- 7 parts
- 6 examples
- vs shadcn/ui
@base-ui/react@tabler/icons-react
Showing 1–10 of 248 results
pnpm dlx shadcn@latest add https://hextaui.com/r/pagination.jsonAdds the component, the HextaUI theme tokens and any HextaUI components it depends on.
Add the theme tokens to your global CSS, if you haven’t yet.
Install the dependencies.
pnpm add @base-ui/react @tabler/icons-react class-variance-authority cnCopy and paste the following code into your project.
components/ui/pagination.tsx components/ui/button.tsx lib/motion.ts Update the import paths to match your project setup.
Give Pagination a count and it builds the whole bar. It always shows the same number of slots, so Previous, Next and the numbers never shift under your cursor while you click through pages. Leave count out to compose the parts yourself.
Click an ellipsis to type a page number. Enter jumps, an out-of-range number shakes the field, and Esc puts the ellipsis back. Turn it off with jump={false}.
When the bar doesn't fit its container, it switches to Previous, “Page 4 of 24” and Next, and switches back when there's room. The label is a jump field too. Force either layout with compact.
With getPageHref, every page is a real link, so it can be opened in a new tab. Plain clicks still call onPageChange.
Without count, build the bar from the parts, as in shadcn/ui. Pass render to use your router's link.
usePagination returns the page and ellipsis items for custom layouts. Chevrons flip in right-to-left text.
| Key | Action |
|---|---|
| Tab | Moves into and out of the bar. Previous and Next stay focusable at the ends. |
| ←→ | Moves between Previous, the pages and Next. Flips in right-to-left layouts. |
| HomeEnd | Moves to the first or last item. |
| Enter | Opens the focused page or the page field. In the field, jumps to that page and focuses it. |
| Esc | Closes the page field and returns focus to the ellipsis. |
- The root is a
<nav>labelled “Pagination”, and the current page hasaria-current="page". - At the first and last page, Previous and Next use
aria-disabledinstead ofdisabled, so focus isn't lost when you reach the end. - The sliding indicator becomes a fade when reduced motion is on.
| Prop | Type | Default |
|---|---|---|
countTotal pages. When set, the bar is built for you; leave it out to compose the parts. | number | – |
page | number | – |
defaultPage | number | 1 |
onPageChange | (page: number) => void | – |
getPageHrefRenders pages as links instead of buttons. | (page: number) => string | – |
siblingsPages shown on each side of the current one. | number | 1 |
boundariesPages always shown at the start and end. | number | 1 |
compactauto switches to Previous, “Page x of y” and Next when the bar doesn't fit. | boolean | "auto" | "auto" |
jumpLets the ellipsis open a page field. | boolean | true |
| Attribute | Description |
|---|---|
data-slot="pagination" | The nav. |
data-slot="pagination-indicator" | The background that glides to the current page. |
| Prop | Type | Default |
|---|---|---|
isActiveMarks the current page with aria-current="page". | boolean | false |
disabledSets aria-disabled and ignores clicks. | boolean | false |
render | ReactElement | (props, state) => ReactElement | <a> |
| Attribute | Description |
|---|---|
data-slot="pagination-link" | Target page links in CSS. |
data-active | Present on the current page. |
| Prop | Type | Default |
|---|---|---|
textPass null for an icon-only button. | ReactNode | "Previous" / "Next" |
disabled | boolean | false |
| Prop | Type | Default |
|---|---|---|
onJumpMakes the ellipsis a page field. Without it, the ellipsis is decorative. | (page: number) => void | – |
countThe highest page the field accepts. | number | – |
| Prop | Type | Default |
|---|---|---|
page | number | – |
count | number | – |
siblings | number | 1 |
boundaries | number | 1 |
Returns items, the clamped page and count, and hasPrevious and hasNext. See the usePagination guide for building your own pager.
- ButtonButtons in every variant and size, with a built-in loading, success and error flow that skips the spinner for fast requests.
- MotionThe easing curves, durations and reduced-motion check every component animates with, plus hooks for size morphs and sliding highlights.
- usePaginationTurns a page and a page count into the list of pages and ellipses to render, keeping its length steady as the page moves.
- BreadcrumbA trail of links to the current page that wraps safely, mirrors in right-to-left layouts and expands collapsed segments in place.
- Navigation menuSite navigation with dropdowns, or one full-width panel that stays open while its content slides between menus.
- SidebarAn app sidebar that collapses to icons or off canvas, stays pinned under your header, and becomes a swipeable sheet on phones.