Pagination
On this page
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="?page=2">2</a></li>
<li><a href="?page=3">3</a></li>
<li><a href="?page=4">4</a></li>
<li><a href="?page=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
Implementation guidelines
Basic Structure
<rh-pagination>must have a nested<ol>element with at least one nested<li>and<a>element.- Each
<a>element must have anhrefattribute that links to the corresponding page.
URL Structure Options
You can implement pagination URLs using any of these approaches:
Option 1: Hash fragments (recommended for client-side routing)
- Example:
example.redhat.com/search/#2,example.redhat.com/search/#3 - If using query parameters, ensure the hash comes after:
example.redhat.com/search/?q=test#2
Option 2: Query parameters
- Example:
example.redhat.com/search?page=2,example.redhat.com/search?page=3 - Can be combined with other query parameters:
example.redhat.com/search?q=test&page=2
Option 3: Path-based URLs
- Example:
example.redhat.com/search/page/2,example.redhat.com/search/page/3
Option 4: Manual control with aria-current
- Set
aria-current="page"on the current page's<a>element - Useful for server-side rendered pagination
How the Current Page is Determined
The component determines the active page in this order:
- Looking for an
aria-current="page"attribute on an<a>tag - Matching the full URL (pathname, search parameters, and hash) against each link's
href - If no match is found, the component logs a warning: "could not determine current link"
rh-pagination
Pagination allows users to navigate between pages of related content.
Use it when content is too long for a single view. Authors must
provide a single <ol> with <li><a> page links where the active
page should have aria-current="page". Tab navigates between controls;
Enter activates. Supports box and open variants, default and small sizes.
Theming
This element uses Red Hat design system theming and can be used in themable contexts.
Slots
3
| Slot Name | Summary | Description |
|---|---|---|
[default]
|
Page link list |
Expects a single |
go-to-page
|
page input label text (go-to-page slot) |
Label text preceding the page number input field. Defaults to
"Page". Customize for internationalization. Visually hidden at
very small widths but always accessible to screen readers via
|
out-of
|
summary: preposition text between page input and total (default: "of") description: | Contains the text displayed between the current page input field and the total page count. Defaults to "of" but can be customized for internationalization or alternate phrasing. |
Attributes
8
| Attribute | DOM Property | Description | Type | Default |
|---|---|---|---|---|
overflow
|
overflow |
Controls which end(s) of the page list are truncated with ellipsis.
Accepts |
|
|
label
|
label |
Accessible label for the |
|
|
label-first
|
labelFirst |
Accessible label for the first-page stepper button. Used by screen readers. Defaults to |
|
|
label-previous
|
labelPrevious |
Accessible label for the previous-page stepper button. Used by screen readers. Defaults to |
|
|
label-next
|
labelNext |
Accessible label for the next-page stepper button. Used by screen readers. Defaults to |
|
|
label-last
|
labelLast |
Accessible label for the last-page stepper button. Used by screen readers. Defaults to |
|
|
size
|
size |
Controls pagination size. Accepts |
|
|
variant
|
variant |
Visual variant. Accepts |
|
|
Methods
7
| Method Name | Description |
|---|---|
fromAttribute(value: string | null)
|
|
firstUpdated()
|
|
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 |
Events
0
None
CSS Shadow Parts
2
| Part Name | Summary | Description |
|---|---|---|
container
|
The outer flex container wrapping stepper buttons, nav, and numeric input |
|
numeric
|
The container for the page input, separator text, and total page link |
CSS Custom Properties
4
| CSS Property | Description | Default |
|---|---|---|
--rh-color-icon-status-disabled |
—
|
|
--rh-pagination-stepper-color |
Stepper icon color override |
var(--rh-color-gray-50, #707070)
|
--rh-pagination-background-focused |
Sets the disabled stepper color. |
—
|
--rh-pagination-accent-color |
Page link color override Page link focus color override Page link focus outline color override Sets the accent color for focus outlines Stepper focus accent border color override Input focus border color override |
var(--rh-color-interactive-primary-default)
|
Design Tokens
35
| Token | Description | Copy |
|---|---|---|
--rh-length-3xl
|
Stepper button size 48px length token |
|
--rh-length-2xl
|
Stepper button size at small size 32px length token |
|
--rh-color-interactive-primary-hover
|
|
|
--rh-color-interactive-primary-visited-default
|
Page link visited color |
|
--rh-color-interactive-primary-visited-hover
|
Page link visited hover color |
|
--rh-color-surface-lighter
|
Page link background in light mode Stepper background in light mode Tertiary surface (light theme) |
|
--rh-color-surface-dark
|
Tertiary surface (dark theme) |
|
--rh-color-text-primary-on-dark
|
Stepper hover/focus icon color Primary text color for dark theme |
|
--rh-color-border-subtle-on-light
|
Stepper hover border in dark mode Subtle border color (light theme) |
|
--rh-color-text-secondary-on-dark
|
Stepper icon color in dark mode Secondary text color for dark theme |
|
--rh-space-xl
|
24px spacer |
|
--rh-space-xs
|
4px spacer |
|
--rh-font-family-heading
|
Stepper typeface Heading font family |
|
--rh-font-size-heading-xs
|
Stepper text size h6 heading font size |
|
--rh-border-width-lg
|
Stepper hover/focus border width 3px border width: Example: Expanded Accordion panel |
|
--rh-color-border-interactive
|
Stepper focus accent border color |
|
--rh-space-2xl
|
32px spacer |
|
--rh-length-4xl
|
Pagination inline size 64px length token |
|
--rh-color-surface-lightest
|
Current page background in light mode Input background in light mode Primary surface (light theme) |
|
--rh-color-surface-darkest
|
Current page background in dark mode Input background in dark mode Primary surface (dark theme) |
|
--rh-color-border-subtle
|
Current page border color Input border color |
|
--rh-color-gray-60
|
Stepper hover border in light mode Disabled icon color in dark mode Input bottom border in dark mode Secondary text (light theme) |
|
--rh-color-text-primary
|
Page link text color Pagination text color |
|
--rh-color-interactive-primary-default
|
Page link color Page link focus color Page link focus outline color Stepper focus outline color Input focus border color |
|
--rh-space-sm
|
Pagination vertical spacing Pagination vertical spacing 6px spacer |
|
--rh-color-red-60
|
Dark brand red |
|
--rh-color-red-40
|
Light brand red |
|
--rh-font-size-body-text-md
|
Input text size Pagination text size 16px font size |
|
--rh-space-lg
|
Pagination horizontal margin 16px spacer |
|
--rh-space-md
|
Pagination horizontal spacing Pagination horizontal spacing 8px spacer |
|
--rh-border-width-sm
|
Stepper border width Input border width Total link underline width 1px border width; Example: Secondary CTA or Button |
|
--rh-color-gray-50
|
Stepper icon color in light mode Stepper icon color Total link underline in light mode Subtle icon |
|
--rh-color-gray-40
|
Disabled icon color in light mode Input bottom border in light mode Total link underline in dark mode Subtle icon (hover state) |
|
--rh-border-radius-default
|
Stepper focus corner rounding Total link focus corner rounding 3px border radius; Example: Card |
|
--rh-border-width-md
|
Pagination focus outline Stepper focus accent border width Input focus border width Total link focus outline width 2px border width: Example: Alert |
|
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.