Skip to content
IndexRequest a UIAboutContact

Reading Progress Bar

A thin bar at the top of an article that fills as you read, plus a back-to-top button.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Build a scrolling article card 300x200px (overflow auto) with six short paragraphs and a 3px progress bar pinned to the top inside the card (position sticky, top 0, full width, dark fill). Update the bar on the container's scroll event with requestAnimationFrame: scale = scrollTop / (scrollHeight - clientHeight) applied as transform scaleX with transform-origin left and no transition. When progress passes 30 percent show a 40px circular "Back to top" button in the bottom right corner (opacity and translateY(8px) over 200ms); pressing it scrolls the container to the top with smooth behaviour. The bar has aria-hidden true; the button has aria-label "Back to top" and a visible focus ring. Show the percentage as small text only if useful. Under prefers-reduced-motion drop the button rise and use instant scrolling.

About this pattern

Definition

A bar fixed to the top of a scrolling area whose width follows how far the reader has scrolled. A back-to-top button appears once the reader is well into the content.

Purpose & UX principles

  • Shows how much is left in long articles and documentation, which makes people more willing to continue.
  • Decorative for sighted readers: it carries no unique information, so it is hidden from assistive technology; the button is a real labelled control.
  • Scroll-linked effects should be cheap: only a transform changes.

Interaction states

  • At top (bar empty, button hidden), reading (bar partly filled), near the end (button visible), focus-visible on the button.

Motion specification

  • The bar scales with transform: scaleX on every scroll frame (no transition) so it tracks exactly.
  • The button fades and rises 8px in 200ms.
  • Reduced motion: the bar still tracks (it is not motion), the button appears without the rise and scrolling to the top is instant.

Responsive behaviour

  • The bar is 3px tall on all sizes; on touch devices the back-to-top button is 44px.
  • Works for the page or any scroll container.

Code

HTML
<div class="wrap"><div class="sc" id="sc"><div class="bar" id="bar" aria-hidden="true"></div><div class="tx" id="tx"></div></div><button class="up" id="up" aria-label="Back to top" tabindex="-1">↑</button></div>

Related patterns

Scroll Reveal

↗
Scroll RevealMotion & Transitions

Progress Indicator

↗
Progress IndicatorLoading & Progress

Top Navigation

↗
Top NavigationNavigation