Quick start guide and documentation
| Class | Element | Purpose |
|---|---|---|
.rsl-pagination |
<ul> |
Main pagination container |
.active |
<li> |
Current page indicator |
.disabled |
<li> |
Disabled prev/next buttons |
.compact |
<ul> |
Smaller size variant |
| Attribute | Where | Purpose |
|---|---|---|
aria-label |
Prev/Next/First/Last links | Descriptive label for screen readers |
aria-current="page" |
Active page link | Indicates current page |
aria-disabled="true" |
Disabled links | Indicates disabled state |
role="navigation" |
Wrapper (optional) | Identifies as navigation landmark |
Smaller pagination for tight spaces or mobile views.
.rsl-pagination.compact a {
padding: 6px 10px;
font-size: 0.875rem;
}
.rsl-pagination .disabled a {
opacity: 0.5;
cursor: not-allowed;
pointer-events: none;
}
The included pagination.js provides automatic table pagination with zero configuration. Simply include the script and add the proper classes:
.rsl-table class.rsl-pagination controlsaria-current="page".disabled classFor custom pagination behavior (e.g., AJAX loading, different page sizes), implement your own click handlers:
// Custom pagination handler
document.querySelectorAll('.rsl-pagination a').forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
// Remove active class from all items
document.querySelectorAll('.rsl-pagination li').forEach(li => {
li.classList.remove('active');
});
// Add active class to clicked item
this.parentElement.classList.add('active');
// Your custom logic here
loadPageContent(this.textContent);
});
});
aria-label attributes on prev/next/first/last links, and use aria-current="page" on the active page.
// After loading new page content
function loadPage(pageNum) {
// Load content...
// Move focus to content area
const contentHeading = document.querySelector('#content h2');
if (contentHeading) {
contentHeading.setAttribute('tabindex', '-1');
contentHeading.focus();
}
}
Pagination works seamlessly with all RSL components:
Card 1
Card 2
Card 3
The Pagination component is fully compatible with RSL's JSON Layout API,
enabling declarative table pagination through JavaScript configuration.
Components automatically initialize after rendering via RSL.JSONLayout.renderLayout().
.rsl-table and .rsl-pagination elements using the JSON API,
the pagination automatically initializes without manual setup.
// Create table HTML with pagination
const tableHTML = `
<table class="rsl-table">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr><td>1</td><td>User 1</td><td>user1@example.com</td></tr>
<!-- Add more rows... -->
</tbody>
</table>
<ul class="rsl-pagination">
<li><a href="#">Previous</a></li>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">Next</a></li>
</ul>
`;
// Render via JSON API - pagination auto-initializes!
const config = {
version: 1,
layoutId: "paginated-table",
breakpoints: { xs: 1 },
items: [{
id: "table-item",
content: { type: "html", value: tableHTML }
}]
};
RSL.JSONLayout.renderLayout('#container', config);
// Pagination is now active - no manual init() needed!
| Method | Description |
|---|---|
RSL.Pagination.init() |
Scan and initialize all paginated tables (auto-called by JSON API) |
RSL.Pagination.create(table, pagination, rowsPerPage) |
Manually create pagination for specific table |
RSL.Pagination.showPage(table, pageNum) |
Programmatically navigate to a specific page |
RSL.Pagination.instances |
Map of initialized table instances |
RSL.Pagination.destroy(table) |
Destroy pagination instance and cleanup FilterBus subscriptions |
Pagination can subscribe to RSL's FilterBus to automatically reset to page 1 when filters change. This is ideal for dashboard scenarios where filter buttons affect table content - when the data changes, users should start at page 1.
data-filter-subscribe="key1,key2" to the pagination elementrsl-pagination:filterbus-reset event when reset occurs| Attribute | Type | Description |
|---|---|---|
data-filter-subscribe |
String | Comma-separated list of FilterBus keys to subscribe to (e.g., "region", "region,dateFilter") |
| Event | Detail | Description |
|---|---|---|
rsl-pagination:filterbus-reset |
{ state, meta, previousPage } |
Fired when pagination resets to page 1 due to a FilterBus update |
.rsl-table),
not Smart Table. The Smart Table component has its own built-in pagination that integrates with its filtering and sorting features.
Use this Pagination component when you have a table using the Tables component with external filter controls.
fa-chevron-left/right) instead of text for a cleaner look
?page=2) for bookmarkable and shareable pagination
<ul class="rsl-pagination">justify-content: centerclass="active" is on the <li> not the <a>.active class at a time.rsl-pagination .disabled a { pointer-events: none; }e.preventDefault()View pagination.html for realistic use cases
Use playground.html as a starting point
Browse all RSL Components and examples