ScrollToTopButton

The ScrollToTopButton component displays a floating button that appears when you scroll down a page and allows users to quickly scroll back to the top.

Usage & Examples

Default

Scroll down the page to make the ScrollToTopButton appear. This demo uses a tall container to simulate a real scroll environment.

default.tsx

<div style={{ height: "200vh", padding: "2rem" }}>
  <p style={{ maxWidth: 600 }}>
    Scroll down the page to make the ScrollToTopButton appear. This demo
    uses a tall container to simulate a real scroll environment.
  </p>
  <ScrollToTop />
</div>

Props API

13 props
Columns
ScrollToTopButton props API
Default
Description
aria-describedbystringNoariaOptional accessible description id applied to the button.
aria-labelstringNoaria"Scroll to top"Accessible label for the scroll-to-top button.
aria-labelledbystringNoariaOptional id of an external label element applied to the button. When provided, this takes precedence over "aria-label" for accessible naming.
classNamestringNostylingAdditional custom class names for the root element of the component.
data-testidstringNotestingBackward-compatible alias for test ID attributes.
idstringNopropsOptional id for the root element.
offsetnumberNoprops300The scroll offset (in pixels) from the top of the page at which the button becomes visible.
roleReact.AriaRoleNoariaOptional role for the outer wrapper if semantic grouping is needed.
roundingRoundingTypeNostylingconfigured default rounding (fallback: "medium")Optional rounding style applied to the button.
shadowShadowTypeNostylingconfigured default shadow (fallback: "light")Optional shadow style for the button.
testIdstringNopropsdataTestId ?? "scroll"Optional test ID for testing frameworks.
titlestringNopropsOptional title attribute for the button. Defaults to the same value as "aria-label" when not provided.