Data pagination


Install
npx shadcn add @klarhimmel/app-data-paginationDetailsAbout, usage, props and more
A pagination row: a summary built from the page, rows per page and the total (it changes with the page and is read out politely), previous and next, numbered pages with…
States
pagination in 4 forms: first page, middle page, last page, no rows.
first page
Showing 1 to 10 of 210 items
middle page
Showing 11 to 20 of 210 items
last page
Showing 201 to 210 of 210 items
no rows
Showing 0 to 0 of 0 items
Notes
When to use it
A row under a list or table that shows the current range and page numbers. For narrowing a list use app-data-filters.
Writing for it
- The summary is built from showing, to, of and noun, plus the numbers, so write them as words that fit between numbers, like Showing, to, of and bookings.
- perPage and total are numbers written as text. The range is computed from the page, so change them together with the pages list.
- pages takes 3 to 9 labels and a gap is written as the ellipsis character. The active label must match one of the entries.
Watch out for
The title is not drawn. It only names the navigation landmark, so an empty one leaves the nav unnamed. The block moves the marker and the summary line but never loads rows, so the host has to swap the data.
Pairs well with
Usage
The block in a page, with its default content (long lists shortened). Every prop is in the table below.
Props
The type, default and text limit of every prop. On a real page, over-limit text is kept and checkSections flags it (Installation, Check a page before you ship); this live preview shows the default until it fits. The panel above edits all props.
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | 'Pagination' | Text, up to 40 characters. |
summary | { showing, to, of, noun } | {…} | Fields: showing, to, of, noun. |
perPage | string | '10' | Text, up to 6 characters. |
total | string | '210' | Text, up to 10 characters. |
pages | string[] | 5 items | List of 3 to 9. |
active | string | '2' | Text, up to 6 characters. |
previous | string | 'Previous' | Text, up to 20 characters. |
next | string | 'Next' | Text, up to 20 characters. |
Install
Installs
- Button
- About
- A pagination row: a summary built from the page, rows per page and the total (it changes with the page and is read out politely), previous and next, numbered pages with a gap marker, and aria-current.
- States
- First page, middle, last (previous or next disabled). The current page has aria-current. New project? Set it up once: /get-started/installation.