DS0
Components

BackToTop

A floating action button that scrolls the page back to the top when clicked.

Overview

BackToTop renders a fixed-position button that appears after the user scrolls past a threshold. Clicking it smoothly scrolls the page back to the top.

Usage

<BackToTop threshold={300} />

Custom Content

<BackToTop threshold={200}>
  <ArrowUp className="h-4 w-4" />
</BackToTop>

API Reference

PropTypeDefaultDescription
thresholdnumber300Scroll distance before showing (px)
smoothbooleantrueUse smooth scrolling
childrenReactNodeArrow iconCustom button content

Accessibility

  • Button has aria-label="Back to top"
  • Keyboard accessible via Tab + Enter
ComponentWhen to Use Instead
StickyElements that stick during scroll
ScrollAreaCustom scrollable containers

On this page