Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Pagination

    Link-based page navigation with Previous and Next links and an ellipsis for skipped pages.

    Pagination

    <x-markas.pagination :page="5" :total="10" href="?page={page}" />
    import { Pagination } from "@/components/markas/Pagination";
    
    <Pagination page={5} total={10} href="?page={page}" />
    import Pagination from "@/components/markas/Pagination.vue";
    
    <Pagination :page="5" :total="10" href="?page={page}" />
    <script lang="ts">
      import Pagination from "$lib/components/markas/Pagination.svelte";
    </script>
    
    <Pagination page={5} total={10} href={"?p={page}"} />
    ---
    import Pagination from "@/components/markas/Pagination.astro";
    ---
    
    <Pagination page={5} total={10} href="?p={page}" />
    import { Component } from "@angular/core";
    import { Pagination } from "./markas/pagination.component";
    
    @Component({
      selector: "markas-example",
      imports: [Pagination],
      template: `<nav markas-pagination page="5" total="10" [href]="href"></nav>`,
    })
    export default class PaginationExample {
      protected readonly href = "?p={page}";
    }

    Examples

    First page

    Last page

    Few pages

    Table footer

    Showing 21 to 30 of 97 results

    Showing 21 to 30 of 97 results

    Showing 21 to 30 of 97 results

    Showing 21 to 30 of 97 results

    Showing 21 to 30 of 97 results

    Installation

    npx markasui@latest add pagination

    Usage

    <x-markas.pagination :page="$users->currentPage()" :total="$users->lastPage()" href="?page={page}" />

    No Alpine.js needed.

    import { Pagination } from "@/components/markas/Pagination";
    
    <Pagination page={5} total={10} href="?page={page}" />;
    <template>
      <Pagination :page="5" :total="10" href="?page={page}" />
    </template>
    <script lang="ts">
      import Pagination from "$lib/components/markas/Pagination.svelte";
    </script>
    
    <Pagination page={5} total={10} href={"?page={page}"} />

    Wrap the pattern in {"..."}, because {page} inside a quoted Svelte attribute is an expression.

    ---
    import Pagination from "@/components/markas/Pagination.astro";
    ---
    
    <Pagination page={5} total={10} href="?page={page}" />

    No client script: the links are plain anchors.

    import { Component } from "@angular/core";
    import { Pagination } from "./markas/pagination.component";
    
    @Component({
      selector: "app-results",
      imports: [Pagination],
      template: `<nav
        markas-pagination
        [page]="page"
        total="10"
        [href]="href"
      ></nav>`,
    })
    export class Results {
      readonly page = 5;
      readonly href = "?page={page}";
    }

    Angular uses an attribute selector on the native nav, so id, class, and other attributes stay on the nav. Bind href from a property, because {page} clashes with template syntax.

    • The number of page buttons stays at siblings * 2 + 5 (7 by default), for example page 5 of 10: 1 … 4 5 6 … 10.
    • pageRange(page, total, siblings) is exported from the React, Vue, Svelte (module script), and Angular versions if you want to build your own layout.
    • The nav is labelled “Pagination” and the links read “Previous” and “Next”. Translate them with navLabel, previousLabel, and nextLabel (Blade: nav-label, previous-label, next-label).

    Props

    NameTypeDefaultDescription
    pagenumber1Current page. Clamped to the range 1 to total.
    totalnumber1Number of pages.
    hrefstring'?page={page}'URL pattern. {page} is replaced with the page number.
    siblingsnumber1Number of pages shown on each side of the current page.
    navLabelstringPaginationAccessible label of the nav element.
    previousLabelstringPreviousText of the previous page link.
    nextLabelstringNextText of the next page link.

    Accessibility

    • Wrapped in a nav labelled by navLabel.
    • The active page has aria-current=page.
    • Previous and Next use rel prev and next, and become an aria-disabled span on the first or last page.
    • The ellipsis is aria-hidden.
    • In a narrow container the Previous and Next text is only visually hidden (sr-only), so the accessible name stays.

    Related components

    More navigation components with the same classes in every framework.