Pagination
Previous and next buttons around numbered page buttons, with ellipses when there are too many pages to show.
<arc-pagination>Overview
Pagination renders previous and next buttons around a row of page numbers. The first and last pages always show, siblings sets how many pages show on each side of the current one, and an ellipsis stands in for the rest.
Set total to the number of pages and current to the active page (1-based). Clicking a page or an arrow fires arc-change with the new page number, and you load that page's data. Previous disables itself on the first page and next on the last.
The control is a <nav> landmark labelled "Pagination". The active page button has aria-current="page", and the arrow buttons are labelled "Previous page" and "Next page".
Guidelines
Do
- Use `siblings="1"` where space is tight and `siblings="2"` where it isn't
- Place it directly below or beside the content it pages
- Add a page-size selector when readers should choose how many items a page shows
Don't
- Don't use it for fewer than 3 pages. Plain previous and next links are simpler
- Don't use it to move between unrelated sections. Use Tabs
Features
- The active page has an accent-primary background and a glow
- `current` is clamped to 1 through `total`, and lowering `total` re-clamps it
Preview
Usage
This component needs JavaScript. Use the Web Component or a framework wrapper.
<arc-pagination total="10" current="3" siblings="1"></arc-pagination>import { Pagination } from '@arclux/arc-ui-react';
export default function Example() {
return (
<Pagination total="10" current="3" siblings="1" />
);
}<script setup>
import { Pagination } from '@arclux/arc-ui-vue';
</script>
<template>
<Pagination total="10" current="3" siblings="1" />
</template><script>
import { Pagination } from '@arclux/arc-ui-svelte';
</script>
<Pagination total="10" current="3" siblings="1" />import { Component } from '@angular/core';
import { Pagination } from '@arclux/arc-ui-angular';
@Component({
imports: [Pagination],
template: `
<arc-pagination total="10" current="3" siblings="1"></arc-pagination>
`,
})
export class MyComponent {}import { Pagination } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<Pagination total="10" current="3" siblings="1" />
);
}import { Pagination } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<Pagination total="10" current="3" siblings="1" />
);
}API
totalnumber1- Total number of pages. At least 1: a pager with no pages is still a pager showing page 1 of 1.
currentnumber1- The currently active page number (1-based). Reflected as an attribute. Clamped to 1..
total, so a page number past either end lands on the nearest real page rather than stranding the control. siblingsnumber1- Number of page buttons to show on each side of the current page before ellipsis truncation kicks in. Never negative.
compactbooleanfalse- Shows only previous/next buttons with a 'current / total' label. Hides individual page numbers.
Events
arc-changedetail:{ value: number }- Fired when the current page changes
See also
- Data GridGrid for tabular data with inline editing, multi-column sorting, pinned columns, row selection and virtual scrolling. Columns are a JavaScript array, and the whole grid is one tab stop with the WAI-ARIA grid keyboard pattern.
- BreadcrumbA trail of links from the site root down to the current page.
- Infinite ScrollContainer that fires a load event as the reader nears the bottom, with a loading spinner and an end-of-list state.