ScrollPremium

Scroll Progress Bar

A 4 px bar stuck to the top of a scrolling panel, filling from left to right exactly as fast as you read: 20% after 100 px, 52% after 260 px, full at the end of the 496 px travel. CSS is enough wherever animation-timeline: scroll() exists; seventeen lines of JavaScript do the same job in Firefox.

CSSProgressSticky

Updated

This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Scroll has 74 effects, including 12 free. Explore the category →

3 usage examples

An episode of a vertical-scroll comic — reading app on a phone — Scroll Progress Bar example 1

① An episode of a vertical-scroll comic — reading app on a phone

WhenA comics reader built for the thumb: an episode is one single strip of six panels that you push up with one gesture. The header keeps the episode number and title.
WhyOn a continuous strip nothing tells you whether two panels are left or twenty. The coral line under the header says so without taking room from the drawing, and it moves back if you scroll up to re-read a panel: it measures position, not time spent.
SettingsA 190 × 284 px area inside the phone screen, 445 px of travel. Bar left at 4 px, solid #ff6b4a fill, beige track. The six panels are .sb-progressbar-block elements 74 to 150 px tall. Capture: a timer in the scene scrolls at 74 px/s in place of the thumb.
This week's lost property — screen outside a school's student office — Scroll Progress Bar example 2

② This week's lost property — screen outside a school's student office

WhenA screen hung by the student office: the list of the twelve items found during the week scrolls by itself, in a loop, with where and when each was found.
WhyIn front of a looping screen, the pupil looking for a water bottle cannot tell whether it has just gone by or is about to come. The thick bar under the title shows where the loop stands: nearly full, wait ten seconds; nearly empty, you are watching from the start.
SettingsA 540 × 290 px area under a 70 px banner, twelve 58 px rows, 551 px of travel. Bar thickened to 10 px (height), yellow #ffd23f fill. The automatic scrolling (64 px/s, back to the top at the end of the list) is a timer in the scene: the effect reads scrolling, it does not produce it.
Index of the 96 varieties in a rose grower's catalogue, from A to Z — Scroll Progress Bar example 3

③ Index of the 96 varieties in a rose grower's catalogue, from A to Z

WhenThe “Index” page of a rose nursery: four letter buttons on the left (A – D, E – K, L – R, S – Z), the list of varieties in a panel on the right. A click brings the chosen range to the top of the panel.
WhyAfter a jump from a button it is easy to lose your place in a long list. The pink line at the head of the panel glides to the new position and places the range within the alphabet: a quarter, halfway, nearly the end. It is the marker; the buttons are the lift.
SettingsA 330 × 322 px area, 809 px of travel, 4 px bar in a pink gradient. The buttons call scrollTo towards the sub-heading of their range (a script in the scene, yours to write); the move is eased by the code's own scroll-behavior: smooth. In the capture a timer clicks in place of the visitor every 1.5 s.

How it works

The first child of the scrolling area (.sdc-scroll-container, 280 px tall) is a track, .sb-progressbar-bar, set to position: sticky; top: 0: it holds the top edge while the content slides beneath. Inside it, .sb-progressbar-fill carries the violet → pink gradient, starts at transform: scaleX(0) with transform-origin: left center, and plays @keyframes fx0547Grow up to scaleX(1). The line that matters is animation-timeline: scroll(): the animation no longer advances with time but with the position of the first scrolling ancestor — here the area, not the page. Checked with two copies on one page: scrolling the second leaves the first bar at zero.

The bar is plain proportion: width = scroll offset ÷ travel. Read in Chromium 149 and WebKit 26.5: 20.2% at 100 px, 52.4% at 260 px, 80.6% at 400 px, 100% at 496 px. Firefox 151 has no animation-timeline; there the supplied script finds each root, pauses the same animation and sets its currentTime on every scroll event: 20.1%, 52.3%, 80.5% at the same positions. The travel is written nowhere: the .sb-progressbar-content tray has no imposed height, it is as tall as what it holds (a heading, a sentence, five 120 px blocks), and the bar adjusts by itself when you add more.

Three flaws of the original code were fixed. The animation only had a to keyframe: in WebKit the bar then moved at the square of the progress — 3.6% at 100 px, 24.6% at mid-scroll, 58.3% at 400 px, where 19, 50 and 76% were expected. The starting keyframe is now spelled out and both engines give the same figures. The tray was a fixed 800 px for 636 px of content: the bar finished its run over 164 px of nothing. And the selectors now hang from .fx-0547-root, with animations renamed fx0547…: several effects in the catalogue share the .sdc-scroll-container and .sdc-scroll-hint classes, and they no longer overwrite one another.

Accessibility

  • Screen readers: the track and its fill are two empty divs marked aria-hidden="true". That is deliberate: CSS cannot publish a value, and a role="progressbar" without an up-to-date aria-valuenow would announce something false. If progress has to be spoken, a script must read scrollTop — this code has none. The area itself is a named region (rewrite the aria-label).
  • Keyboard: tabindex="0" makes the area reachable with Tab in Chromium, Firefox and WebKit — the last one skipped it in the original code. Focus shows (2 px violet outline, 7.3:1 against the background), then arrow keys, Space and Page Down scroll; the bar follows as it does with the wheel (four arrow presses = 160 px = 32% in Chromium).
  • Reduced motion: the bar is kept under prefers-reduced-motion: reduce. It only moves when the reader scrolls and it answers that gesture: it is a marker, not decorative animation. What is removed: the pulsing of the “Scroll” hint and the area's scroll-behavior: smooth. To hide the bar anyway, one display: none rule on .sb-progressbar-bar inside that same query is enough.
  • Contrast and touch: the fill reaches 4.7:1 at its violet end and 5.6:1 at its pink end against #0a0a0f (computed), above the 3:1 asked of a graphic element. The empty track, white at 10%, is nearly invisible (1.25:1): until something has scrolled, nothing suggests a bar is there. With a finger the area scrolls natively (a 150 px swipe read as 151 px in touch emulation) and 4 px is not a target: the bar is shown, never handled.

Browser compatibility

animation-timeline: scroll(): Chrome and Edge 115, Safari 26, Firefox 159 according to MDN. Below that the script drives the bar; it needs Element.getAnimations() (Firefox 75, Safari 13.1). Measured: the CSS route in Chromium 149 and WebKit 26.5, the JavaScript route in Firefox 151, no console error. position: sticky has been safe everywhere for years. Not tried: Firefox 159 and later, a real Safari, a real phone.

Chrome 115+✓ Full, in CSS (measured in Chromium 149)
Edge 115+✓ Not verified (same engine as Chrome)
Safari 26+✓ Full in the WebKit 26.5 test build; real Safari not verified
Firefox 75 to 158✓ Full, through the JavaScript fallback (measured in Firefox 151)
Firefox 159+✓ Not verified (CSS route announced by MDN)
Safari 13.1 to 25✓ Not verified (should go through the JavaScript fallback)
iOS 26+ / Android Chrome 115+✓ Not verified on a device

Two safety nets, in this order. If the browser ignores animation-timeline, the @supports block is skipped and the script takes over (it steps aside by itself as soon as the property is recognised). If the script is missing or blocked too, the fill stays at scaleX(0): an empty 4 px track at the top of the panel, with no error and nothing hidden.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0547-root">
  <div class="sdc-scroll-container" tabindex="0" role="region" aria-label="…">
    <div class="sb-progressbar-bar" aria-hidden="true">
      <div class="sb-progressbar-fill"></div>
    </div>
    <div class="sb-progressbar-content">
      <h4>…</h4>
      <p>…</p>
      <div class="sb-progressbar-block"></div>
      … ×5
    </div>
  </div>
  <span class="sdc-scroll-hint" aria-hidden="true">…</span>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Thickness (CSS — .sb-progressbar-bar { height: 4px }) 4 px 2 px for a discreet hairline above a text, 8 to 10 px for a screen read from a distance. The fill takes the full height of the track.
Colours (CSS — .sb-progressbar-fill { background }, .sb-progressbar-bar { background }) gradient #8b5cf6 → #ec4899 over white at 10% A solid colour reads better over 4 px than a gradient. Raise the track to about 25% white if it must be seen before the first scroll.
Direction (CSS — transform-origin: left center) left to right right center fills from the right (pages in Arabic or Hebrew); center opens the bar from the middle.
What the bar measures (CSS — animation-timeline: scroll()) the nearest scrolling area, top to bottom scroll(root) follows the whole page; scroll(inline) follows a horizontal scroll. In both cases the fallback script still listens to .sdc-scroll-container: adapt it as well.
Panel height (CSS — .sdc-scroll-container { height: 280px }) 280 px Any height, or a fluid one (60vh). The travel, and so the filling speed, recomputes by itself.
Hint (HTML — span.sdc-scroll-hint) “Scroll ↓” over the bottom of the frame A demo prop: delete the element and the fx0547HintPulse rule once the panel holds your own content.

FAQ

In nothing you can see on screen, and that is worth knowing before you buy. Progress Bar is the same 4 px sticky bar, the same gradient, the same animation on scroll(), the same fallback script — and it is free. What this version adds is finish: an area reachable by keyboard in Safari with a name for screen readers, a reduced-motion setting, selectors hung from the root, a tray that follows its content instead of a fixed 800 px. If Progress Bar is already in your project, this one will not change the look.
Yes, with two edits. Take the track out of the area and set it to position: fixed; top: 0; left: 0, then write animation-timeline: scroll(root) on the fill. For Firefox, replace the area with document.documentElement in the script and listen to scroll on window. The shipped version targets a panel on purpose: that is the case most reading bars do not cover.
Not with this code. Progress only exists as a transform applied by the browser; no value is exposed to the page. For a readable “52%” or a button that unlocks at the bottom, you have to read scrollTop, scrollHeight and clientHeight in JavaScript — three lines, which we do not ship here so that the bar stays in CSS.