Components · Status and navigation

Pagination

Pagination here is a “load more” pattern: a counter, a thin progress bar and a button that adds more items to a list without a page load.

How to add pagination to a list. The files are components/css/pagination.css and components/js/pagination.js.

Basic Usage

Link the shared files once per page. Never copy the rules into a page.

StepWhat to do
1. Link<link rel="stylesheet" href="/components/css/button.css"> and pagination.css, then <script src="/components/js/pagination.js"></script>.
2. PlacePut the component last in the section or list. Add no padding below it.
3. KeyPick a key (for example products). The ids {key}-pagination-count, {key}-pagination-bar and pagination-{key} must exist.
4. UpdateAfter loading items call updatePagination(key, visible, total).

Pagination

Copy the markup you need.


API

Classes

ClassUse
paginationThe component: 190px, centered, space above.
pagination__infoCounter and bar.
pagination__countThe counter text.
pagination__progressThe 2px track.
pagination__progress-barThe fill, width set by script.

Function

FunctionWhat it does
updatePagination(key, visible, total)Sets the counter, the fill width and disables the button when visible >= total.

Things to know

  • No padding or margin below the component: the section provides it.
  • The button is always btn btn--secondary btn--md.
  • When everything is shown the button is disabled, never hidden or removed.

CSS / Tailwind

The component is one CSS file and one JS file, shared by every page. Link them, never copy them. The code below is read from the files the page links, so it is always what you see.

CSS (components/css/pagination.css)
JS (components/js/pagination.js)