Pagination
Pagination with page navigation, next and previous links.
Pagination is the page navigation for a list. Only one PaginationLink carries isActive. PaginationPrevious/Next and PaginationEllipsis cover the ends and the gaps.
Shorthand: <Pagination page={2} total={5} /> renders Previous, the numbered links 1 to total with page active, and Next. The links it generates all point to #, so use the composed form when you need real hrefs.
Installation
$ bext ui add pagination
Copy and paste the following into src/components/ui/pagination.tsx.
Usage
Anatomy
<Pagination>
└── <PaginationContent> // <ul>
├── <PaginationItem><PaginationPrevious href="?p=1" /></PaginationItem>
├── <PaginationItem><PaginationLink isActive href="?p=2">2</PaginationLink></PaginationItem>
├── <PaginationItem><PaginationEllipsis /></PaginationItem>
└── <PaginationItem><PaginationNext href="?p=3" /></PaginationItem>API Reference
Pagination
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | Composed form: a PaginationContent. Rendered inside <nav role="navigation" aria-label="Pagination">. |
| ariaLabel | string | "Pagination" | aria-label of the <nav>. Change it when a page has two paginations. |
| page | number | — | Shorthand: the active page. Used only together with total. |
| total | number | — | Shorthand: number of pages. Generates Previous, links 1..total and Next. |
| className | string | — | Extra classes on the <nav>. |
PaginationContent
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | The PaginationItems. Rendered as a <ul> (flex row, gap-1). |
PaginationItem
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | One link, Previous, Next or ellipsis. Rendered as an <li>. |
PaginationLink
| Prop | Type | Default | Description |
|---|---|---|---|
| href | string | "#" | Target of the page link. |
| isActive | boolean | false | Sets aria-current="page" and the outline button style (ghost otherwise). |
| children | ReactNode | — | Page number. The link is a fixed 36px square (h-9 w-9). |
| className | string | — | Extra classes on the <a>. |
PaginationPrevious / PaginationNext
| Prop | Type | Default | Description |
|---|---|---|---|
| href | string | "#" | Target of the link. The text ("Previous" / "Next") and the aria-label ("Go to previous page" / "Go to next page") are fixed. |
| className | string | — | Extra classes on the <a>. |
PaginationEllipsis
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | "More pages" | Visually hidden text read by assistive technologies in place of the three-dot icon. |
| className | string | — | Extra classes on the around the icon. |
Accessibility
The nav has aria-label="Pagination" (ariaLabel to change it). The active page has aria-current="page"; the attribute is absent on the other links. PaginationEllipsis contains the visually hidden text "More pages" (label to change it), so skipped pages are announced.
PaginationPrevious and PaginationNext set aria-label="Go to previous page" and "Go to next page"; these two strings and the visible "Previous" / "Next" are fixed in English.
Edit this component live in the bext playground. The PRISM + signals version is the bext-native idiom: fine-grained reactivity, no virtual DOM.
On This Page