Pagination
On this page
Implementation guidelines
<rh-pagination>
must have a nested<ol>
element with at least one nested<li>
and<a>
element.- Pagination URLs must start with a hash, eg
#2
.- We recommend structuring your pagination URL as follows:
example.redhat.com/search/#2
- If your URL contains query parameters (eg:
?search=test
), ensure the hash comes after the query parameter. - Ensure the hash for the
href
in the first page of the pagination is#
and not#1
.
- We recommend structuring your pagination URL as follows:
- The active page is set in this order:
- Looking for an
aria-current="page"
attribute on a<a>
tag - Looking in the URL for a hash, eg
/search/#2
- If neither of these are set and no hashes exist in the URL,
<rh-pagination>
sets the current page to the first<a>
in the list - If
<rh-pagination>
cannot determine the current link from these conditions, it will log a message to the console saying, "Could not determine current link."
- Looking for an
Importing
Add rh-pagination to your page with this import statement:
<script type="module">
import '@rhds/elements/rh-pagination/rh-pagination.js';
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
To learn more about installing RHDS elements on your site using an import map read our getting started docs.
Lightdom CSS
This element requires you to load "Lightdom CSS" stylesheets for styling deeply slotted elements.
Note
Replace /path/to/
with path to the CSS file, whether local or CDN.
<link rel="stylesheet" href="/path/to/rh-pagination/rh-pagination-lightdom.css">
Usage
<rh-pagination>
<ol>
<li><a href="#">1</a></li>
<li><a href="#2">2</a></li>
<li><a href="#3">3</a></li>
<li><a href="#4">4</a></li>
<li><a href="#5">5</a></li>
</ol>
</rh-pagination>
<link rel="stylesheet" href="../rh-pagination-lightdom.css">
<script type="module">
import '@rhds/elements/rh-pagination/rh-pagination.js';
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
rh-pagination
A paginator allows users to navigate between pages of related content.
Slot Name | Summary | Description |
---|---|---|
go-to-page |
"Go to page" text, defaults to "Page" |
|
out-of |
"of" text |
|
|
An ordered list of links |
Attribute | DOM Property | Description | Type | Default |
---|---|---|---|---|
overflow |
overflow |
Override |
|
|
label |
label |
Accessible label for the 'nav' element |
|
|
label-first |
labelFirst |
Accessible label for the 'first page' button |
|
|
label-previous |
labelPrevious |
Accessible label for the 'previous page' button |
|
|
label-next |
labelNext |
Accessible label for the 'next page' button |
|
|
label-last |
labelLast |
Accessible label for the 'last page' button |
|
|
size |
size |
Change pagination size to small |
|
|
variant |
variant |
"Open" variant |
|
|
Method Name | Description |
---|---|
first() |
Navigate to the first page |
prev() |
Navigate to the previous page |
next() |
Navigate to the next page |
last() |
Navigate to the last page |
go(page: 'first' | 'prev' | 'next' | 'last' | number) |
Navigate to a specific page |
Part Name | Summary | Description |
---|---|---|
numeric |
shared container for the numeric controls at all widths |
|
container |
pagination container |
|
numeric-middle |
container for the numeric control at medium screen widths |
|
numeric-end |
container for the numeric control at small and large screen widths |
CSS Property | Description | Default |
---|---|---|
--rh-pagination-accent-color |
var(--rh-color-interactive-blue, #0066cc)
|
|
--rh-pagination-background-focused |
var(--rh-color-gray-20, #c7c7c7)
|
|
--rh-pagination-stepper-color |
var(--rh-color-icon-subtle, #707070)
|
|
--rh-pagination-stepper-color |
var(--rh-color-gray-50, #707070)
|
|
--rh-pagination-background-focused |
var(--rh-color-gray-30, #c7c7c7)
|
|
--rh-pagination-accent-color |
var(--rh-color-interactive-primary-default)
|
Token | Copy |
---|---|
--rh-length-3xl
|
|
--rh-space-xs
|
|
--rh-color-interactive-primary-hover
|
|
--rh-color-interactive-primary-visited-default
|
|
--rh-color-interactive-primary-visited-hover
|
|
--rh-color-surface-lighter
|
|
--rh-color-surface-dark
|
|
--rh-color-text-primary-on-dark
|
|
--rh-color-border-subtle-on-light
|
|
--rh-color-text-secondary-on-dark
|
|
--rh-color-gray-50
|
|
--rh-font-family-heading
|
|
--rh-font-size-heading-xs
|
|
--rh-border-width-lg
|
|
--rh-color-border-interactive
|
|
--rh-color-gray-30
|
|
--rh-space-2xl
|
|
--rh-length-2xl
|
|
--rh-length-4xl
|
|
--rh-color-surface-lightest
|
|
--rh-color-surface-darkest
|
|
--rh-border-width-sm
|
|
--rh-color-border-subtle
|
|
--rh-color-gray-40
|
|
--rh-color-gray-60
|
|
--rh-color-text-primary
|
|
--rh-color-interactive-primary-default
|
|
--rh-space-sm
|
|
--rh-space-md
|
|
--rh-color-red-60
|
|
--rh-color-red-40
|
|
--rh-font-size-body-text-md
|
|
--rh-border-radius-default
|
|
--rh-border-width-md
|
|
--rh-space-lg
|
|
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.