Skip to content

Reading progress

A thin bar across the top of the window that fills as the reader moves through one article.

<div class="cap-reading-progress" aria-hidden="true"></div>
<main class="cap-page" data-context="prose">
  <h1>Field notes</h1>
  <article data-cap-reading id="rp-article" style="padding-block-end: calc(10 * var(--space-9))">
    <p>The spring survey covered twelve sites along the creek, each visited once a week from March to May.</p>
    <p>Counts rose through April and fell in the first week of May, when the water was highest.</p>
    <p>Two sites were dry for most of March and are left out of the totals.</p>
    <p>The full counts, by site and by week, are in the annual report.</p>
    <p>Next season adds three sites upstream and moves the visits to Tuesdays.</p>
    <p>Thanks to Alex Rivera, Sam Lee and Jordan Park for the fieldwork.</p>
    <p>Questions go to the team at example.com.</p>
    <p>The method is the same as last year's, so the two seasons can be compared site by site.</p>
    <p>Weather notes for each visit are kept beside the counts.</p>
    <p>That is the whole of the spring.</p>
  </article>
  <p style="block-size: 30rem">After the article.</p>
</main>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/reading-progress.css";

Usage

<div class="cap-reading-progress" aria-hidden="true"></div>
<article data-cap-reading>…</article>

API reference

CSS variables

VariableDefault
--reading-progress-colorvar(--accent)
--reading-progress-size3px
--reading-progress-top0

Parts and data attributes

ClassIs
.cap-reading-progressthe root
AttributeValues
data-cap-readingpresent or absent

Accessibility

Nothing to reach: the bar is not interactive.