Skip to the page content

Pagination

Ways through a long list, from page numbers to infinite scroll.

13 pagination types

Page numbers

Bootstrap's own pagination in the palette: Previous and Next, a gap for the pages left out, the current page filled and a disabled end that is still readable.

NumberedBootstrap markup
Show code
<nav aria-label="Order pages">
  <ul class="pagination">
    <li class="page-item disabled">
      <a class="page-link" aria-disabled="true">Previous</a>
    </li>
    <li class="page-item active"><a class="page-link" href="#" aria-current="page">1</a></li>
    <li class="page-item"><a class="page-link" href="#">2</a></li>
    <li class="page-item disabled"><span class="page-link">…</span></li>
    <li class="page-item"><a class="page-link" href="#">14</a></li>
    <li class="page-item"><a class="page-link" href="#">Next</a></li>
  </ul>
</nav>

Icons, first and last

Chevrons in place of words, and double chevrons to jump to either end. Each icon carries a hidden label for screen readers.

NumberedBootstrap markup
Show code
<li class="page-item">
  <a class="page-link" href="#">
    <i class="bi bi-chevron-double-left" aria-hidden="true"></i>
    <span class="visually-hidden">First</span>
  </a>
</li>
<li class="page-item">
  <a class="page-link" href="#">
    <i class="bi bi-chevron-left" aria-hidden="true"></i>
    <span class="visually-hidden">Previous</span>
  </a>
</li>

Sizes

.pagination-lg and .pagination-sm either side of the default, for a spacious page or a dense table.

StylesBootstrap markup
Show code
<ul class="pagination pagination-lg">…</ul>
<ul class="pagination">…</ul>
<ul class="pagination pagination-sm">…</ul>

Alignment

Flex utilities on the list line it up at the start, the middle or the end of its row.

StylesBootstrap markup
Show code
<ul class="pagination justify-content-center">…</ul>
<ul class="pagination justify-content-end">…</ul>

Pill and ghost

Two extra looks for Bootstrap's own markup: .basalt-pagination-pill spaces the pages out as round buttons, and .basalt-pagination-ghost drops the boxes until you point at one.

StylesBasalt upgrade

Pill

Ghost

Show code
<ul class="pagination basalt-pagination-pill">…</ul>
<ul class="pagination basalt-pagination-ghost">…</ul>

Cursor pagination

Newer and Older for a feed that keeps growing, where page 3 would mean something different a minute later. The middle says which stretch you are looking at.

Previous and nextBasalt upgrade

    Show code
    <div class="basalt-cursor-pager">
      <ul>…</ul>
      <div class="basalt-cursor-pager-bar">
        <button type="button" class="btn btn-sm btn-outline-secondary" disabled>
          <i class="bi bi-arrow-left" aria-hidden="true"></i>Newer
        </button>
        <p class="basalt-cursor-pager-caption" aria-live="polite">
          Orders from <strong>2:02 pm</strong> back to <strong>1:18 pm</strong>
        </p>
        <button type="button" class="btn btn-sm btn-outline-secondary">
          Older<i class="bi bi-arrow-right" aria-hidden="true"></i>
        </button>
      </div>
    </div>
    <!-- Older asks the server for ?before=<last id>, Newer for ?after=<first id>. -->

    Record stepper

    For a detail page: the orders either side are named, so you know where a click will take you, and the middle shows where this one sits. J and K step while the pager has focus.

    Previous and nextBasalt upgrade

    Show code
    <div class="basalt-record-pager" role="group" aria-label="Orders to pack">
      <a class="basalt-record-pager-link" href="order-details.html?id=%23472">
        <i class="bi bi-chevron-left" aria-hidden="true"></i>
        <span class="basalt-record-pager-text">
          <span class="basalt-record-pager-dir">Previous</span>
          <span class="basalt-record-pager-name">Order #1041</span>
        </span>
      </a>
      <p class="basalt-record-pager-pos"><strong>3 / 12</strong><span>to pack</span></p>
      <a class="basalt-record-pager-link basalt-record-pager-link-next" href="order-details.html?id=%23474">
        <i class="bi bi-chevron-right" aria-hidden="true"></i>
        <span class="basalt-record-pager-text">
          <span class="basalt-record-pager-dir">Next</span>
          <span class="basalt-record-pager-name">Order #1043</span>
        </span>
      </a>
    </div>

    Mini pager

    "2 / 4" and two small arrows, sized for a card header where a full row of page numbers would not fit.

    CompactBasalt upgrade

    Best sellers this week

      Show code
      <div class="basalt-minipager" role="group" aria-label="Best sellers pages">
        <button type="button" class="basalt-minipager-btn" aria-label="Previous page" disabled>
          <i class="bi bi-chevron-left" aria-hidden="true"></i>
        </button>
        <span class="basalt-minipager-pos" aria-live="polite">1<span> / 4</span></span>
        <button type="button" class="basalt-minipager-btn" aria-label="Next page">
          <i class="bi bi-chevron-right" aria-hidden="true"></i>
        </button>
      </div>

      Dots

      For slides, tips and short step-throughs. The current dot stretches into a bar; the arrow keys move along the row, which is a single tab stop.

      CompactBasalt upgrade
      Tip 1 of 5
      Show code
      <div class="basalt-dots" role="group" aria-label="Visit tips">
        <button type="button" class="basalt-dots-dot" aria-label="Tip 1: Text before you set off"
                aria-current="true"></button>
        <button type="button" class="basalt-dots-dot" aria-label="Tip 2: Photos before and after"></button>
        …
      </div>
      
      <script>
        basaltDots(document.querySelector('.basalt-dots'), (index) => showTip(index));
      </script>

      Load more with progress

      A button that adds the next six under the list. A bar and a line say how far through you are, placeholder rows fill the gap while it loads, and focus lands on the first new row.

      Load moreBasalt upgrade
      • Horn buttons, 20 mmTailoring · bin A1$18.50
      • Silk lining, violetTailoring · bin A2$24.00
      • Suede elbow patchesTailoring · bin A4$67.50
      • Hand-sewing silk, 6 colorsTailoring · bin A5$89.00
      • Canvas interlining, 2 m rollTailoring · bin A6$34.50
      • Woven care labelsTailoring · bin A6$14.00

      Showing 6 of 23 items

      Show code
      <div class="basalt-loadmore">
        <ul data-basalt-loadmore-list>…</ul>
        <div class="basalt-loadmore-foot">
          <div class="basalt-loadmore-meter" aria-hidden="true">
            <span data-basalt-loadmore-bar></span>
          </div>
          <p class="basalt-loadmore-status" aria-live="polite"
             data-basalt-loadmore-status></p>
          <button type="button" class="btn btn-outline-secondary basalt-loadmore-btn"
                  data-basalt-loadmore-btn>
            <span class="spinner-border" aria-hidden="true"></span>
            <i class="bi bi-arrow-down basalt-loadmore-icon" aria-hidden="true"></i>
            <span data-basalt-loadmore-label>Load 6 more</span>
          </button>
          <p class="basalt-loadmore-done" data-basalt-loadmore-done hidden>That's all.</p>
        </div>
      </div>
      
      <script>
        basaltLoadMore(el, {
          total: 23, batch: 6, noun: 'items',
          fetch: (offset, count) => fetch(`/supplies?offset=${offset}&count=${count}`)
            .then((r) => r.json()).then((rows) => rows.map(toListItem))
        });
      </script>

      Infinite scroll

      The next batch loads as the end of the box comes into view. A switch turns that off and brings back a button, for anyone who wants to reach what sits below the list.

      Load moreBasalt upgrade
      • Sandra Franklinpaid for order #21402 min ago
      • Phyllis Delaneyhad order packed: #21399 min ago
      • Sabrina Kavanaghreviewed Two-Tone Oxfords16 min ago
      • Patricia Pembertonreordered Private Styling Session23 min ago
      • Eleanor Fairweatherpaid for order #213630 min ago
      • Iva Blackwoodhad order packed: #213537 min ago
      • Benjamin Hartleyreviewed Shield Sunglasses44 min ago
      • Rodney Forbesreordered Draped Column Gown51 min ago

      8 of 40 events loaded

      Show code
      <div class="basalt-infinite">
        <div class="basalt-infinite-box" data-basalt-infinite-box tabindex="0"
             role="region" aria-label="Store activity, more loads as you scroll">
          <ul data-basalt-infinite-list>…</ul>
          <div class="basalt-infinite-sentinel" data-basalt-infinite-sentinel></div>
          <p class="basalt-infinite-end" data-basalt-infinite-end hidden>That's everything.</p>
        </div>
        <div class="basalt-infinite-foot">
          <div class="form-check form-switch">
            <input class="form-check-input" type="checkbox" role="switch" id="auto"
                   checked data-basalt-infinite-auto>
            <label class="form-check-label" for="auto">Load as I scroll</label>
          </div>
          <p class="basalt-infinite-status" aria-live="polite" data-basalt-infinite-status></p>
          <button type="button" class="btn btn-sm btn-outline-secondary"
                  data-basalt-infinite-more hidden>Load more</button>
        </div>
      </div>
      
      <script>
        basaltInfinite(el, { total: 40, batch: 8, noun: 'events', fetch: loadEvents });
      </script>

      Letter index

      A to Z over a long directory. Letters with nobody under them are struck through and skipped; the row is one tab stop and the arrow keys move along it.

      IndexBasalt upgrade

        Show code
        <div class="basalt-alpha" role="toolbar" aria-label="Customers by first letter">
          <button type="button" class="basalt-alpha-key basalt-alpha-key-all"
                  aria-pressed="false" tabindex="-1">All</button>
          <button type="button" class="basalt-alpha-key" aria-pressed="true"
                  aria-label="A, 2 customers">A</button>
          <button type="button" class="basalt-alpha-key" disabled
                  aria-label="F, no customers">F</button>
          …
        </div>

        Everything a long table needs under it: rows per page, the range on show, page buttons that fold the middle into a gap, and a box to jump straight to a page. Focus stays on the button you used.

        Table footerBasalt upgrade
        Orders, newest first
        Order Customer Items Status Total

        Show code
        <div class="basalt-pager">
          <div class="basalt-pager-size">
            <label class="basalt-pager-label" for="per">Rows</label>
            <select class="form-select form-select-sm" id="per" data-basalt-pager-size>
              <option>5</option><option selected>10</option><option>25</option>
            </select>
          </div>
          <p class="basalt-pager-range" aria-live="polite" data-basalt-pager-range></p>
          <nav class="basalt-pager-nav" aria-label="Order pages, table footer">
            <ul class="pagination pagination-sm mb-0" data-basalt-pager-pages></ul>
          </nav>
          <form class="basalt-pager-jump" data-basalt-pager-jump novalidate>
            <label class="basalt-pager-label" for="jump">Go to page</label>
            <input type="number" class="form-control form-control-sm" id="jump" min="1"
                   aria-describedby="jump-error">
            <button type="submit" class="btn btn-sm btn-outline-secondary">Go</button>
          </form>
          <p class="basalt-pager-error" id="jump-error" data-basalt-pager-error hidden></p>
        </div>
        
        <script>
          basaltPager(document.querySelector('.basalt-pager'), {
            total: 137,
            noun: 'orders',
            render(from, to) { /* draw rows from..to */ }
          });
        </script>