Skip to main content Red Hat Design System logo Contribute on Github

Back to top

Overview Style Guidelines Code Accessibility


Back to top component is a fragment link that allows users to quickly navigate to the top of a lengthy content page.

Example of a back to top button


What do these mean?
Figma library:
RH Elements:


View a demo below.


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>
<script type="module">
import '@rhds/elements/rh-back-to-top/rh-back-to-top.js';
import '@patternfly/elements/pf-icon/pf-icon.js';

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;

<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';
Full screen demo

When to use

  • When content fills up more than two screens in length at medium and large breakpoints
  • When content fills up more than four screens in length at small breakpoints
Property Status Meaning
Figma library Ready Component is available in the Figma library
Responsive Ready Component responds to changing viewport sizes in Figma and the browser
RH Elements Ready Component is available as a web component
webRH Planned Component is scheduled to become a web component

Other libraries

To learn more about our other libraries, visit this page.

© 2021-2024 Red Hat, Inc. Deploys by Netlify