Pagination
Navigation between pages of a large dataset. It draws the page range from data-ts-total (the page count), collapses the middle into “…”, and can show a page-size selector (data-ts-page-size-control).
Navigation · TaishoDS Core, in plain HTML.
Examples
One working example per case. Each example is the HTML of its preview—copy it as is, and with Core’s CSS and JS loaded, it looks and works the same.
Long project list, 20 pages
When to use
- There are many records, and users need to know how many there are and which page they’re on.
- Users need to be able to go back to a specific page.
- It helps to let users choose how many items to see per page.
When not to use
- The content has a reading order and isn’t a dataset →
pager. - The list is short and fits in full. Don’t split it.
- It’s a table that already handles its own paging →
table.
Do
- Show the total. It tells users how much is left.
- Keep the page in the URL so it can be shared and revisited.
Don’t
- Don’t paginate five items at a time. It forces people to click constantly.
- Don’t mix pagination and infinite scroll in the same list.
TaishoDS Core
Needs Core’s JS, which hooks in through data-ts-* attributes.
Core owns the current page. As static HTML, it doesn’t change pages.
Core hooks into it through these attributes. They go in the markup, and there’s nothing to initialize.
data-ts-itemsdata-ts-label-emptydata-ts-label-templatedata-ts-pagedata-ts-page-ellipsisdata-ts-page-itemdata-ts-page-nextdata-ts-page-prevdata-ts-page-sizedata-ts-paginationdata-ts-pagination-listdata-ts-totaldata-ts-value
What it does: Marks the active page, redraws the window of page numbers, and announces the change with an event. It includes the first and last page buttons (data-ts-page-first and data-ts-page-last), the “11–20 of 200” label (data-ts-page-label), and the page-size selector (data-ts-page-size-control). Every button has its own accessible name.
| Attribute | What it does |
|---|---|
data-ts-label-template | On the <nav>. The label template, with {from}, {to}, and {total}. Without it, the Spanish default {from}–{to} de {total}. |
data-ts-label-empty | On the <nav>. The label when there are no items. Without it, the Spanish default 0 resultados. |
From the CDN, without a build, load taisho.pagination.css along with taisho.base.css. Also load:
taisho.button.csstaisho.checkbox.csstaisho.icon.csstaisho.input.csstaisho.kbd.csstaisho.select.csstaisho.spinner.css
For how Core works in general, see Behavior.
Accessibility
- It goes in a navigation
<nav>. The buttons have anaria-label(“Page 12”, one per number, also when the window redraws), and the current page setsaria-current. - The previous/next buttons are disabled at either end.
Verification
What was actually tested. Anything that wasn’t tested says so—we’d rather say “not verified” than claim too much.
- axe WCAG 2.2 A + AA in a real browser, in light and dark mode, before every release.
- keyboard Adds no keys of its own—it uses the browser’s native behavior.
- screen reader Not verified with a screen reader. Test it in your own combination of components, not just here, where each one appears alone and on its happy path.