Back to components
ElementMiscFree

Back to Top React component

A floating scroll-to-top button that fades in past a threshold, with an optional progress ring showing how far down the page you are.

About the Back to Top component

Back to Top is a free floating round button. It springs into view once the page is scrolled past a threshold, and clicking it scrolls back to the top. An accent-colored ring around the arrow fills clockwise as the reader moves down the page.

threshold (default 400px), showProgress, smooth, position ("bottom-right", "bottom-left" or "bottom-center"), offset (default 24px), size, theme, accentColor and a custom icon are props. It watches the window by default, or any scrollable element passed as containerRef. The button shows only an icon, so label (default "Back to top") is used as its aria-label.

When to use it

Use it on long articles, documentation, changelogs and product listings where readers go far down the page.

To show reading progress at the top of the page instead, use Scroll Progress Bar.

Installation

Add the Back to Top component to your project with the shadcn CLI. It lands in components/back-to-top.tsx as plain React + Tailwind CSS source you own and can edit.

Install
Copied!
npx shadcn@latest add @reactframe/back-to-top

Or copy the source by hand and install its dependencies:

Install
Copied!
npm install motion clsx tailwind-merge

Related components

Copy Button
Free
Terminal
Free
Inline Edit
Free
Fieldset
Free
Shape Divider
Free
Section Container
Free