Back to top
Installation
We recommend import maps when building pages with RHDS. Learn more about how to install on our getting started docs.
<script type="importmap">
{
"imports": {
"@rhds/elements/": "https://www.redhatstatic.com/dx/v1-alpha/@rhds/elements@2.1.2/elements/",
}
}
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
npm install @rhds/elements
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
<script type="importmap">
Could not generate import map using JSPM: Cannot read properties of undefined (reading '@rhds/elements')
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
Add it to your page with this import statement
<script type="module">
import '@rhds/elements/rh-back-to-top/rh-back-to-top.js';
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
Usage
<div id="overflow">
<rh-back-to-top href="#">Back to top</rh-back-to-top>
</div>
<script type="module">
import '@rhds/elements/rh-back-to-top/rh-back-to-top.js';
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
rh-back-to-top
Back to top component is a fragment link that allows users to quickly navigate to the top of a lengthy content page.
Slot Name | Description |
---|---|
|
Text for the back to top link |
Attribute | DOM Property | Description | Type | Default |
---|---|---|---|---|
visible |
visible |
Flag to always show back to top button, defaults to false. |
|
|
scrollable-selector |
scrollableSelector |
Element selector to spy on for scrolling. Not passing a selector defaults to spying on window scroll events |
|
|
scroll-distance |
scrollDistance |
Distance from the top of the scrollable element to trigger the visibility of the back to top button |
|
|
href |
href |
Page fragment link to target element, must include hash ex: #top |
|
|
Part Name | Description |
---|---|
trigger |
back to top link anchor element |
Token | Copy |
---|---|
--rh-border-radius-pill
|
|
--rh-border-width-md
|
|
--rh-color-accent-base-on-light
|
|
--rh-color-border-strong-on-dark
|
|
--rh-color-interactive-primary-hover-on-light
|
|
--rh-color-text-primary-on-dark
|
|
--rh-font-size-body-text-xs
|
|
--rh-line-height-body-text
|
|
--rh-space-3xl
|
|
--rh-space-md
|
|
--rh-space-xl
|
|
--rh-space-xs
|
|
Other libraries
To learn more about our other libraries, visit the getting started page.