Overview
Back to top component is a fragment link that allows users to quickly navigate to the top of a lengthy content page.
- Figma library
-
Ready - Responsive
-
Ready - RH Elements
-
Ready - webRH
-
Planned
Demos
View a live version of this component and see how it can be customized.
<div id="overflow">
<a id="top" href="#bottom">Go to bottom</a>
<p>Scroll down or press tab to see the back to top button</p>
<a id="bottom" href="#top">Go to top</a>
<rh-back-to-top href="#top">Back to top</rh-back-to-top>
</div>
<script type="module">
import '@rhds/elements/rh-back-to-top/rh-back-to-top.js';
import '@patternfly/elements/pf-icon/pf-icon.js';
</script>
<style>
main {
display: block;
scroll-behavior: smooth;
max-height: calc(100dvh - var(--pf-demo-header-height)) !important;
}
#nav {
height: calc(100dvh - var(--pf-demo-header-height, 4.375rem)) !important;
}
#overflow {
min-height: calc(100dvh + 401px);
position: relative;
}
#bottom {
position: absolute;
bottom: 0;
}
@media (prefers-reduced-motion: reduce) {
main {
scroll-behavior: auto;
}
}
</style>
<script type="module">
/* add support for demo/fullscreen and dev server */
const b2t = document.querySelector('rh-back-to-top');
const main = document.querySelector('main');
// if main isn't scrollable use window
if (window.getComputedStyle(main).overflow === 'scroll') {
b2t.scrollableSelector = 'main';
}
</script>
<rh-back-to-top>
demo in a new tabWhen to use
Status checklist
Property | Status | Meaning |
---|---|---|
Figma library |
|
Component is available in the Figma library |
Responsive |
|
Component responds to changing viewport sizes in Figma and the browser |
RH Elements |
|
Component is available as a web component |
webRH |
|
Component is scheduled to become a web component |
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.
Red Hat legal and privacy links
- About Red Hat
- Jobs
- Events
- Locations
- Contact Red Hat
- Red Hat Blog
- Diversity, equity, and inclusion
- Cool Stuff Store
- Red Hat Summit