Docs

Main site

Installation Browser support Extend config MCP server
Validation Page speed testing Responsive design
Accordion Aspect Ratio Avatar Badge Banner Bento Grid Blockquote Breadcrumbs Button Callout Card Drawer Dropdown Link Modal Navbar Navblock Pagination Popover Progress Separator Tabs Timeline Toast Tooltip
Checkbox Datepicker File upload Form field Input Label OTP Radio Range Select Textarea Toggle
Header Footer
Accordion Auth Checkbox & Radio Content Drawers Features Modals Statistics & Metrics Teams Dropdowns
Address Contact number Currency symbol Date Emirates ID Name
Close
Home Documentation Components Pagination

Pagination

Pagination breaks long lists — search results, service tickets, news archives, document libraries — into navigable pages. It gives users a clear sense of how much content is available, where they are in the set, and a quick way to jump backward or forward. The component is fully controlled — you decide which page is current and update it on every change event.

Navigation
Status
Active
Introduced
4.0.x
View source code

Anatomy

aegov-pagination renders a single <nav> landmark wrapping a <ul> of buttons: Previous, an optional First before it and Last after Next, page-number buttons with ellipsis tokens between distant ranges (or, in compact mode, a plain "page X of Y" text indicator instead of page numbers).

Image showing anatomy of a pagination control

Item Name Description
1 Nav landmark The <nav> element, labelled "Pagination"
2 Previous / Next Always rendered; disabled at the first/last page
3 First / Last Optional, shown only when is-enabled-first-last is set
4 Page button One per visible page number; the active one carries aria-current="page"
5 Ellipsis Decorative, marks a collapsed range of hidden page numbers

Basic pagination

aegov-pagination is controlled: when the user clicks a page, the component only emits aegovPaginationPageChange with the new page number — your application must update page-current in response (and load the data for that page). Without wiring this event, clicking a page button has no visible effect at all.

<aegov-pagination id="pager" pages="10" page-current="1"></aegov-pagination>

<script>
  const pager = document.getElementById('pager');
  pager.addEventListener('aegovPaginationPageChange', (e) => {
    pager.pageCurrent = e.detail;
    // load data for the new page…
  });
</script>

Total pages and current page

pages is the total page count and page-current is the active page (1-indexed) — both drive the render. When pages is 1, Previous and Next are disabled and a single page-1 button remains as the current-page indicator. When pages is 0 or less, the component renders nothing at all.

<aegov-pagination pages="6" page-current="3"></aegov-pagination>
<aegov-pagination pages="1" page-current="1"></aegov-pagination>

First and Last buttons

Set is-enabled-first-last="true" to show explicit First and Last buttons alongside Previous and Next — useful for very long lists where a user wants to jump straight to either end.

<aegov-pagination pages="50" page-current="12" is-enabled-first-last="true"></aegov-pagination>

Sibling and boundary counts

count-sibling controls how many pages appear on each side of the current page; count-boundary controls how many pages always stay visible at the start and end. Both default to 1. Increase them when there's plenty of horizontal space and users benefit from seeing more surrounding context.

Default (1 sibling, 1 boundary)

2 siblings each side

2 siblings + 2 boundary pages

<aegov-pagination pages="50" page-current="20"></aegov-pagination>
<aegov-pagination pages="50" page-current="20" count-sibling="2"></aegov-pagination>
<aegov-pagination pages="50" page-current="20" count-sibling="2" count-boundary="2"></aegov-pagination>

Compact variant

variant="compact" hides individual page numbers and shows only Previous, Next, and a "page X of Y" indicator — the recommended layout for narrow viewports and sidebars. The indicator sits inside a polite aria-live region, so assistive technology announces the new position whenever the page changes.

<aegov-pagination variant="compact" pages="20" page-current="3"></aegov-pagination>
<aegov-pagination variant="compact" pages="20" page-current="3" is-enabled-first-last="true"></aegov-pagination>

Sizes

size accepts sm, base (default), and lg.

<aegov-pagination size="sm" pages="10" page-current="3"></aegov-pagination>
<aegov-pagination size="base" pages="10" page-current="3"></aegov-pagination>
<aegov-pagination size="lg" pages="10" page-current="3"></aegov-pagination>

Responsive sizes

size also accepts a Tailwind-style responsive string. Each segment overrides smaller breakpoints, so the example below is sm on phones, base from the md breakpoint up, and lg from lg up.

<aegov-pagination size="sm md:base lg:lg" pages="20" page-current="3"></aegov-pagination>

Disabled state

Set is-disabled="true" to disable every button. The current page is still announced to assistive technology, but no click emits an event — typical uses are freezing the pager while data loads, or after a server error.

<aegov-pagination pages="10" page-current="3" is-disabled="true"></aegov-pagination>

Custom labels for localization

Override the visible button text with label-prev, label-next, label-first, and label-last. The built-in defaults are already bilingual (English/Arabic, auto-selected from the page direction) — reach for these props only when you need bespoke wording rather than a straight translation.

<aegov-pagination
  pages="20"
  page-current="5"
  is-enabled-first-last="true"
  label-prev="Back"
  label-next="Forward"
  label-first="Start"
  label-last="End"
></aegov-pagination>

Practical example: service tickets list

Combining the pager with a results region. The change event updates page-current and rewrites the visible record range — in a real service this is where you would call your API for the next batch of records.

My service requests

Showing records 1 – 10 of 47

  • SR-2026-0001 — Vehicle registration renewal
  • SR-2026-0002 — Family residence visa
  • SR-2026-0003 — Trade licence amendment
<div id="tickets" class="p-6 border border-aeblack-200 rounded-lg">
  <h3 class="text-lg font-semibold mb-4">My service requests</h3>
  <p class="text-aeblack-500 mb-4">Showing records <span id="tickets-range">1 – 10</span> of 47</p>
  <ul class="text-aeblack-700 list-disc ms-5">
    <li>SR-2026-0001 — Vehicle registration renewal</li>
    <li>SR-2026-0002 — Family residence visa</li>
    <li>SR-2026-0003 — Trade licence amendment</li>
  </ul>
</div>

<div class="mt-4">
  <aegov-pagination id="tickets-pager" pages="5" page-current="1" count-sibling="1"></aegov-pagination>
</div>

<script>
  const total = 47;
  const perPage = 10;
  const pager = document.getElementById('tickets-pager');
  const rangeEl = document.getElementById('tickets-range');

  pager.addEventListener('aegovPaginationPageChange', (e) => {
    pager.pageCurrent = e.detail;
    const start = (e.detail - 1) * perPage + 1;
    const end = Math.min(e.detail * perPage, total);
    rangeEl.textContent = `${start} – ${end}`;
  });
</script>

RTL support

The control is direction-agnostic — it reads dir="rtl" from the closest ancestor carrying a dir attribute (or the document root). In RTL mode the Previous/Next/First/Last chevrons mirror automatically, the list flows right-to-left, and the built-in labels switch to their Arabic strings.

<div dir="rtl">
  <aegov-pagination
    pages="12"
    page-current="4"
    is-enabled-first-last="true"
  ></aegov-pagination>
</div>

Usage

Here is the recommended usage of pagination on any website or application. These are recommended usage guides, however the developer must use the best practices of web and application development to accurately use this component.

Always update page-current in response to aegovPaginationPageChange
The component is fully controlled — without the update, a click has no visible effect at all. Update the property, then load the data for the new page.

Move focus or scroll position after a page change
A keyboard user who just activated "Next" is still focused on that button — if the results region is far away or replaced entirely, they can lose their place. Move focus to (or scroll to) the updated content.

Reach for the compact variant on narrow viewports
Letting individual page-number buttons wrap onto a second line on a small screen is harder to scan than a single "Page 3 of 10" indicator with Previous/Next either side.

Don't forget is-enabled-first-last on very long lists
Past roughly 50 pages, jumping from page 1 to page 50 by clicking Next dozens of times is a real usability problem — enable explicit First/Last buttons.

Rename the landmark when a page has more than one pager
An aria-label set on <aegov-pagination> is forwarded to the inner <nav> and replaces the built-in "Pagination" label — for example aria-label="Search results pages" — so screen-reader users can tell several pagination landmarks apart.

Don't set count-sibling/count-boundary so high that ellipsis never appears on a long list
The whole point of the collapsed range is to keep the control compact — pushing the counts up until every page number is always visible defeats that, and on a narrow layout the row will simply wrap.

API reference

The following are the properties and references of a pagination control

Properties

AttributeDescriptionTypeDefault

field-id

DOM id for the inner <nav> element. Auto-generated if omitted.

string

auto-generated

pages

Total number of pages. The component renders nothing when pages is 0 or less.

number

1

page-current

Currently active page (1-indexed). This is a controlled prop — update it in response to every aegovPaginationPageChange event.

number

1

is-enabled-first-last

Show explicit First and Last buttons alongside Previous and Next.

boolean

false

count-sibling

Number of sibling pages shown on each side of the current page.

number

1

count-boundary

Number of pages always visible at each boundary (start and end of the list).

number

1

variant

default shows page numbers, ellipsis, and prev/next buttons. compact shows only prev/next (and first/last, if enabled) plus a "page X of Y" indicator.

default | compact

'default'

size

Size token, or a Tailwind-style responsive string.

sm | base | lg

'base'

is-disabled

Disables every button. The current page is still announced to assistive technology, but no click emits an event.

boolean

false

label-prev

Visible label on the Previous button. Empty falls back to a localized string ("Previous"/"السابق").

string

''

label-next

Visible label on the Next button. Empty falls back to a localized string ("Next"/"التالي").

string

''

label-first

Visible label on the First button (only shown when is-enabled-first-last is true). Empty falls back to a localized string ("First"/"الأول").

string

''

label-last

Visible label on the Last button (only shown when is-enabled-first-last is true). Empty falls back to a localized string ("Last"/"الأخير").

string

''

Slots

Note

This component exposes no slots — its entire layout is driven by props.

Events

EventDetailDescription

aegovPaginationPageChange

number

Fired when the user clicks a navigation or page button. The detail is the new 1-indexed page. Not emitted for the current page, for a page outside 1–pages, or while is-disabled. The component does not update page-current itself — your handler must, or nothing visibly changes.

Pass-through attributes

Attribute groupForwarded?Where applied

aria-*, data-*

Yes

The inner <nav> element. An aria-label here replaces the built-in "Pagination" label.

class, style

Allowed

The host element.

id

Not forwarded

Use field-id — it sets the inner <nav>'s real id.

Notes

The following notes are applicable of this component.

Built-in accessibility

  • Renders as a <nav> landmark with aria-label="Pagination" (Arabic: "ترقيم الصفحات") so screen readers announce it among page landmarks.
  • The active page button carries aria-current="page" and a descriptive aria-label such as "Page 3, current page" (Arabic: "الصفحة 3، الصفحة الحالية").
  • Previous, Next, First, and Last buttons are named by their visible text: the built-in bilingual label ("Previous", "Next", "First", "Last"; Arabic "السابق", "التالي", "الأول", "الأخير" when dir="rtl" is detected) or your label-* value. Their chevron icons are aria-hidden.
  • The compact variant's position indicator ("Page 3 of 10" / "الصفحة 3 من 10") sits in a polite aria-live region, announced whenever the page changes.
  • Disabled buttons set both the native disabled attribute and aria-disabled="true".
  • Ellipsis tokens are aria-hidden="true" — decorative only, never announced.

Developer responsibilities

  • Always update page-current in response to aegovPaginationPageChange — the component never updates its own state; without the update, clicking does nothing.
  • After a page change, move focus to (or scroll to) the updated content region so keyboard users don't lose their place — the button just activated may become disabled (e.g. Next on the last page) and drop focus.
  • In the default variant there is no live region, so announce the new result range yourself (e.g. an aria-live="polite" summary next to the results).
  • Prefer compact on narrow viewports rather than letting page-number buttons wrap onto a second line.
  • Enable is-enabled-first-last on lists beyond roughly 50 pages, so users can reach either end without repeatedly clicking Next.
  • label-* props set both the visible text and the accessible name, so voice-control users can say what they see (WCAG 2.2 SC 2.5.3 Label in Name). Keep custom labels short and clear, e.g. "Previous page".
  • Never hide .pagination__nav-label with display: none or visibility: hidden: that text is the button's only name. To show just the chevrons on small screens, hide the text visually (a screen-reader-only style) so it is still read out.

Keyboard support

Key Action
Tab Move focus to the next pagination button. Disabled buttons are skipped.
Shift + Tab Move focus to the previous pagination button.
Enter, Space Activate the focused button.

Notes

  • An unrecognised variant falls back to default and logs a console warning in development builds only; an unrecognised size token falls back to base silently.
  • Setting count-sibling/count-boundary high enough that every page number always fits removes the ellipsis entirely — this is expected, not a bug: the algorithm only collapses a range when doing so would hide two or more page numbers.