Pagination

Pagination helps users move through a long collection of results one page at a time.

tsx
import { Pagination } from '@/components/ui/wideset/pagination/Pagination';

<Pagination
  pagesCount={12}
  defaultActivePage={3}
  maxVisiblePages={5}
/>

Installation

pnpm dlx wideset add pagination

Copies the component and any Wideset components it uses into your project.

Examples

Types

numbers shows up to maxVisiblePages page buttons and folds the pages in between into an ellipsis menu, so users can jump to a nearby page in one click. overflow swaps the buttons for Prev, a page select and Next: it stays the same width however many pages there are, which suits long result sets and narrow toolbars. The current page carries aria-current="page" and the arrow buttons have their own accessible names.

tsx
import { Pagination } from '@/components/ui/wideset/pagination/Pagination';

export default function PaginationTypes() {
  return (
    <div className="gap-ws-12 flex flex-col">
      <Pagination type="numbers" pagesCount={10} defaultActivePage={3} />
      <Pagination type="overflow" pagesCount={10} defaultActivePage={3} />
    </div>
  );
}

Rows per page

Pass rowsPerPageOptions when users should choose how dense each page is, such as a long table of invoices; leave it out when the page size is fixed or set elsewhere. The selector and the page controls then sit at opposite ends of the bar. Pagination does not move the user back to page 1 when the size changes: do that in onChangeItemsPerPage, or the active page may point past the end.

tsx
import { Pagination } from '@/components/ui/wideset/pagination/Pagination';

export default function PaginationRowsPerPage() {
  return (
    <div className="gap-ws-12 flex flex-col">
      <Pagination pagesCount={10} defaultActivePage={3} />
      <Pagination
        pagesCount={10}
        defaultActivePage={3}
        defaultItemsPerPage={25}
        rowsPerPageOptions={[10, 25, 50]}
      />
    </div>
  );
}

API reference

Pagination

NameDescriptionDefault
activePage

Controlled active page value.

number
—
defaultActivePage

Initial active page in uncontrolled mode.

number
1
defaultItemsPerPage

Initial rows-per-page value in uncontrolled mode.

number
10
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
ellipsisPlaceholder

Placeholder shown inside the ellipsis page-range select trigger. Defaults to `'...'`.

string
'...'
itemsPerPage

Controlled rows-per-page value.

number
—
maxVisiblePages

Maximum number of numbered page buttons rendered around the current page.

number
7
navigationAriaLabel

Accessible label for the pagination nav element. Defaults to `'pagination'`.

string
'pagination'
nextLabel

Visible next button label in overflow mode.

string
'Next'
nextPageAriaLabel

Accessible label for the next-page button when it has no visible text. Defaults to `'Go to next page'`.

string
'Go to next page'
ofLabel

Visible label shown before the total page count in overflow mode.

string
'of'
onChangeActivePage

Called whenever the active page changes.

((page: number) => void)
—
onChangeItemsPerPage

Called whenever the rows-per-page selection changes.

((itemsPerPage: number) => void)
—
pagesCount

Total number of pages available. Must be greater than or equal to 1.

number
1
prevLabel

Visible previous button label in overflow mode.

string
'Prev'
prevPageAriaLabel

Accessible label for the previous-page button when it has no visible text. Defaults to `'Go to previous page'`.

string
'Go to previous page'
rowsPerPageLabel

Visible label shown before the rows-per-page select.

string
'Rows per page'
rowsPerPageOptions

Rows-per-page options. Pass `false` to hide the rows-per-page section entirely.

false | number[]
false
selectPageAriaLabel

Returns the accessible label for the ellipsis page-range select. Receives the first and last hidden page numbers. Defaults to `` `Select page between ${from} and ${to}` ``.

((from: number, to: number) => string)
—
type

Pagination layout variant. Use `numbers` for direct page buttons or `overflow` for compact navigation.

PaginationType
'numbers'

Pagination.Numbers

NameDescriptionDefault
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true

Pagination.Overflow

NameDescriptionDefault
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
nextLabel

Optional override for the next button label.

string
—
ofLabel

Optional override for the label shown before the total page count.

string
—
prevLabel

Optional override for the previous button label.

string
—

Pagination.RowsPerPage

NameDescriptionDefault
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
label

Optional override for the rows-per-page label.

string
—
options

Optional override for the selectable rows-per-page options.

number[]
—

Accessibility

  • The root is a nav landmark labelled by navigationAriaLabel; give it a specific label when a page has more than one (“Invoices pages”).
  • The current page carries aria-current="page"; arrow buttons have their own names.
tsx
import { Pagination } from '@/components/ui/wideset/pagination/Pagination';

<Pagination
  pagesCount={12}
  defaultActivePage={3}
  maxVisiblePages={5}
/>

Appearance

Type

Content

Visible pages
Rows per page