Skip to content

Back To Top

Free

A small floating button for long pages. It shows after you scroll down, its ring fills as you read, and a press goes back to the top.

  • Base UI
  • Motion
  • React 19
  • Tailwind CSS 4

Added Nov 17, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

Put BackToTop once on a long page with a BackToTopButton in it. Pass a skip link as focusTarget, so focus lands there after the scroll.

docs-page.tsx

BackToTop

<div>
PropTypeDefaultDescription
containerRefObject<HTMLElement | null>—The element that scrolls, for a panel or a Scroll Area viewport. Without it the page counts, and the button floats at the end-bottom corner of the window. With it, place BackToTop as the last child inside that element: it sticks to its end-bottom corner.
thresholdnumber400The scroll in px before it shows. Default 400.
showOn"scroll""scroll-up""scroll"scroll: it shows past the threshold (default). scroll-up: only while the reader scrolls back up.
offsetnumber0Lifts it by this many px, above a bottom bar, a cookie bar, or a chat launcher. Default 0.
focusTargetRefObject<HTMLElement | null>—Where focus lands after the scroll: a skip link or the page heading. Default: the container, or the body.
disabledbooleanfalseHides it and stops the work.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

BackToTopButton

<button>
PropTypeDefaultDescription
classNamestring—
busyboolean—The button waits for the app (busy words): a spinner, aria-busy, and no clicks. Focus stays on the button. The style hook stays data-loading.
spinnerPlacement"center""start"—center (default): the spinner covers the label. start: it takes the leading icon slot. The icon sizes always use center, because their one icon is the label.
glass"clear""dark""light"—
size"default""lg""sm""default"sm 36px (with a 44px touch target), default 44px, or lg 52px.
shortcutstring | null"Home"The key the tooltip names. Default "Home"; null shows no key.
From Base UIButtonBase UI docs
focusableWhenDisabledbooleanfalseWhether the button should be focusable when disabled.
render—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
style—Style applied to the element, or a function that returns a style object based on the component's state.
...props<button> attributes—Every other attribute goes to the <button>, with a ref.

BackToTopPill

<button>
PropTypeDefaultDescription
classNamestring—
busyboolean—The button waits for the app (busy words): a spinner, aria-busy, and no clicks. Focus stays on the button. The style hook stays data-loading.
spinnerPlacement"center""start"—center (default): the spinner covers the label. start: it takes the leading icon slot. The icon sizes always use center, because their one icon is the label.
glass"clear""dark""light"—
size"default""icon""icon-lg""icon-sm""icon-xs""lg""sm""xl""xs""default"
From Base UIButtonBase UI docs
focusableWhenDisabledbooleanfalseWhether the button should be focusable when disabled.
render—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
style—Style applied to the element, or a function that returns a style object based on the component's state.
...props<button> attributes—Every other attribute goes to the <button>, with a ref.
  • Use it on pages longer than about three screens.
  • Use BackToTopPill on docs pages, where the label and the read percent help.
  • Use showOn="scroll-up" when the button should stay out of the way while the reader reads down.
  • Use offset to lift it above a cookie bar, a bottom bar, or a chat launcher.
EnterorSpaceOn the button: scrolls back to the top, then moves focus to focusTarget.
Show and hide
panel · it rises in from below and fades out
Scroll back
none · Motion eases the scroll for 250 to 600ms, longer for a longer page; a wheel or a touch stops it
Press
press · 100ms · scales to 0.97 and the shadow drops
Read progress
none · the ring follows the scroll in each frame

Built with

Installs with Back To Top

  1. AddedBack To Top, with Badge, Button, Kbd, Portal, Scroll Progress, Tooltip.
Open the release