Skip to content
VinUIComponentsPagination

Pagination

Links to move between pages of results. Same markup and props in every style: switch the style in the header to see it change.

Basic

Arrows, the first and last page, and the pages around this one. Gaps show an ellipsis.

pagination-basic.html
<nav class="vin-pagination" aria-label="Pagination">
  <ul class="vin-pagination__list">
    <li><a class="vin-btn vin-btn--ghost vin-btn--icon" href="#" aria-label="Previous page"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 6-6 6 6 6"/></svg></a></li>
    <li><a class="vin-btn vin-btn--ghost vin-pagination__page" href="#">1</a></li>
    <li><a class="vin-btn vin-btn--outline vin-pagination__page" href="#" aria-current="page">2</a></li>
    <li><a class="vin-btn vin-btn--ghost vin-pagination__page" href="#">3</a></li>
    <li><span class="vin-pagination__ellipsis" aria-hidden="true">…</span></li>
    <li><a class="vin-btn vin-btn--ghost vin-pagination__page" href="#">10</a></li>
    <li><a class="vin-btn vin-btn--ghost vin-btn--icon" href="#" aria-label="Next page"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 6 6 6-6 6"/></svg></a></li>
  </ul>
</nav>

With labels

"Previous" and "Next" as words. At the first page, Previous is disabled.

pagination-labels.html
<nav class="vin-pagination" aria-label="Pagination">
  <ul class="vin-pagination__list">
    <li><a class="vin-btn vin-btn--ghost" role="link" aria-disabled="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 6-6 6 6 6"/></svg> Previous</a></li>
    <li><a class="vin-btn vin-btn--outline vin-pagination__page" href="#" aria-current="page">1</a></li>
    <li><a class="vin-btn vin-btn--ghost vin-pagination__page" href="#">2</a></li>
    <li><a class="vin-btn vin-btn--ghost vin-pagination__page" href="#">3</a></li>
    <li><a class="vin-btn vin-btn--ghost" href="#">Next <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 6 6 6-6 6"/></svg></a></li>
  </ul>
</nav>

Simple

Just Previous and Next with the page count, for phones and feeds.

pagination-simple.html
<nav class="vin-pagination" aria-label="Pagination">
  <ul class="vin-pagination__list">
    <li><a class="vin-btn vin-btn--outline vin-btn--sm" href="#"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 6-6 6 6 6"/></svg> Previous</a></li>
    <li><span class="vin-pagination__status">Page 2 of 10</span></li>
    <li><a class="vin-btn vin-btn--outline vin-btn--sm" href="#">Next <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 6 6 6-6 6"/></svg></a></li>
  </ul>
</nav>

Installation

React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:

Terminal
npx @vinish/ui add pagination
React
import { Pagination, pageRange } from "@/components/vin/pagination";
Vue
import Pagination, { pageRange } from "@/components/vin/pagination.vue";
Svelte
import Pagination, { pageRange } from "$lib/components/vin/pagination.svelte";

The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.

Plain HTML: the classes come with the style's stylesheet. It needs no JavaScript.

API

From spec/pagination.json, which every framework version is tested against.

PropValuesDefaultIn HTML
page
This page (1-based).
number—aria-current="page" and .vin-btn--outline on its link
count
How many pages there are.
number——
href
Link for a page. Without it, pages are buttons and onPageChange is called.
(page: number) => string——
onPageChange(page: number) => void——
siblings
Pages shown each side of this one before an ellipsis.
number1—
labels
Show "Previous" and "Next" as words, not only arrows.
booleanfalse—
simple
Previous, "Page 2 of 10", Next — no page numbers.
booleanfalse.vin-pagination__status

Parts

React, Vue, SvelteHTML classes
<Pagination>.vin-pagination.vin-pagination__list.vin-pagination__page.vin-pagination__ellipsis.vin-pagination__status

Accessibility

  • A <nav> named "Pagination" with a list of links.
  • This page has aria-current="page"; screen readers say "current page".
  • Arrow-only links have an aria-label ("Previous page", "Next page").
  • At the first or last page the link is disabled with aria-disabled="true" and no href, so it can't be followed or focused.
  • Every page link is at least 36 by 36 pixels.