Tearsheet

Issue 01 · Navigation · p.53

Pagination

Page links with previous/next, a current page and a gap for skipped pages.

Why it works: Give arrow-only links an aria-label. Use real links (with URLs) so pages can be bookmarked and opened in new tabs.

Try it:
Receipt: axe clean · contrast 6.28:1 · 6 tab stops · RTL ✓ · long text ✓

Tab order

  1. link "Previous page":
  2. link "1":
  3. link "2":
  4. link "3":
  5. link "12":
  6. link "Next page":

What assistive tech is given

- navigation "Pagination":
  - link "Previous page":
    - /url: "#"
  - link "1":
    - /url: "#"
  - link "2":
    - /url: "#"
  - link "3":
    - /url: "#"
  - link "12":
    - /url: "#"
  - link "Next page":
    - /url: "#"

Automated checks in CI (axe in Chromium, reduced motion on). They catch a lot, not everything: still try it with a screen reader.

See it in the zine npx -y tearsheet add pagination

Needs the shared tokens.css once per project.

HTML + CSS

index.html
<!-- tearsheet pagination vec753872 · https://qusaialjbali.github.io/tearsheet/zine/parts/pagination.html -->
<nav class="pagination" aria-label="Pagination">
  <a class="page" href="#" aria-label="Previous page"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><path d="m12 5-5 5 5 5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></a>
  <a class="page" href="#">1</a>
  <a class="page" href="#" aria-current="page">2</a>
  <a class="page" href="#">3</a>
  <span class="page-gap" aria-hidden="true">…</span>
  <a class="page" href="#">12</a>
  <a class="page" href="#" aria-label="Next page"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><path d="m8 5 5 5-5 5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></a>
</nav>
styles.css
/* tearsheet pagination vec753872 · https://qusaialjbali.github.io/tearsheet/zine/parts/pagination.html */
.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.page, .page-gap {
  display: grid;
  place-items: center;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.page {
  color: var(--ui-text);
  text-decoration: none;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface);
}
.page:hover { background: var(--ui-surface-2); }
.page:focus-visible { outline: none; box-shadow: var(--ui-focus); }
.page[aria-current="page"] { color: var(--ui-accent-text); background: var(--ui-accent); border-color: var(--ui-accent); }
.page-gap { color: var(--ui-muted); min-width: 24px; padding: 0; }

React

Pagination.jsx
/* tearsheet pagination vec753872 · https://qusaialjbali.github.io/tearsheet/zine/parts/pagination.html */
import './Pagination.css';

export function Pagination() {
  return (
    <nav className="pagination" aria-label="Pagination">
      <a className="page" href="#" aria-label="Previous page"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><path d="m12 5-5 5 5 5" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/></svg></a>
      <a className="page" href="#">1</a>
      <a className="page" href="#" aria-current="page">2</a>
      <a className="page" href="#">3</a>
      <span className="page-gap" aria-hidden="true">…</span>
      <a className="page" href="#">12</a>
      <a className="page" href="#" aria-label="Next page"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><path d="m8 5 5 5-5 5" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/></svg></a>
    </nav>
  );
}
Pagination.css
/* tearsheet pagination vec753872 · https://qusaialjbali.github.io/tearsheet/zine/parts/pagination.html */
.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.page, .page-gap {
  display: grid;
  place-items: center;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.page {
  color: var(--ui-text);
  text-decoration: none;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface);
}
.page:hover { background: var(--ui-surface-2); }
.page:focus-visible { outline: none; box-shadow: var(--ui-focus); }
.page[aria-current="page"] { color: var(--ui-accent-text); background: var(--ui-accent); border-color: var(--ui-accent); }
.page-gap { color: var(--ui-muted); min-width: 24px; padding: 0; }

Vue

Pagination.vue
<!-- tearsheet pagination vec753872 · https://qusaialjbali.github.io/tearsheet/zine/parts/pagination.html -->
<template>
  <nav class="pagination" aria-label="Pagination">
    <a class="page" href="#" aria-label="Previous page"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><path d="m12 5-5 5 5 5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></a>
    <a class="page" href="#">1</a>
    <a class="page" href="#" aria-current="page">2</a>
    <a class="page" href="#">3</a>
    <span class="page-gap" aria-hidden="true">…</span>
    <a class="page" href="#">12</a>
    <a class="page" href="#" aria-label="Next page"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><path d="m8 5 5 5-5 5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></a>
  </nav>
</template>

<style scoped>
.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.page, .page-gap {
  display: grid;
  place-items: center;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.page {
  color: var(--ui-text);
  text-decoration: none;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface);
}
.page:hover { background: var(--ui-surface-2); }
.page:focus-visible { outline: none; box-shadow: var(--ui-focus); }
.page[aria-current="page"] { color: var(--ui-accent-text); background: var(--ui-accent); border-color: var(--ui-accent); }
.page-gap { color: var(--ui-muted); min-width: 24px; padding: 0; }
</style>

Svelte

Pagination.svelte
<!-- tearsheet pagination vec753872 · https://qusaialjbali.github.io/tearsheet/zine/parts/pagination.html -->
<nav class="pagination" aria-label="Pagination">
  <a class="page" href="#" aria-label="Previous page"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><path d="m12 5-5 5 5 5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></a>
  <a class="page" href="#">1</a>
  <a class="page" href="#" aria-current="page">2</a>
  <a class="page" href="#">3</a>
  <span class="page-gap" aria-hidden="true">…</span>
  <a class="page" href="#">12</a>
  <a class="page" href="#" aria-label="Next page"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><path d="m8 5 5 5-5 5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></a>
</nav>

<style>
.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.page, .page-gap {
  display: grid;
  place-items: center;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.page {
  color: var(--ui-text);
  text-decoration: none;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface);
}
.page:hover { background: var(--ui-surface-2); }
.page:focus-visible { outline: none; box-shadow: var(--ui-focus); }
.page[aria-current="page"] { color: var(--ui-accent-text); background: var(--ui-accent); border-color: var(--ui-accent); }
.page-gap { color: var(--ui-muted); min-width: 24px; padding: 0; }
</style>