Christian Heilmann

A CSS only time progress bar to use in markdown / GitHub Pages

Friday, September 5th, 2025 at 7:34 am

For our weekly WeAreDevelopers Live Show I wanted to have a way to include a time progress bar into the page we show. The problem there was that these are markdown files using GitHub Pages and whilst I do use some scripting in them, I wanted to make sure that I could have this functionality in pure CSS so that it can be used on GitHub without having to create an html template. And this is it:

Progress bars in action

The bars support dark and light mode and should be pretty bullet proof. You can check out the demo page to see the effect in action with the liquid source code or play with the few lines of CSS in this codepen. Fork the repo to use it in your pages or just copy the `_includes` folder.

Using the CSS time progress bar

You can use as many bars as you want to in a single page. The syntax to include a bar in a markdown file is the following:

{​% include cssbar.html duration="2s" id="guesttopic" styleblock="yes" %​}

  • The `duration` variable defines how long the progress should take
  • The `id` variable is necessary to and has to be unique to make the functionality work
  • If the `styleblock` is set, the include will add a `style` with the necessary css rules so you don’t have to add them to the main site styles. You only need to do that in one of the includes.

Using the bar in HTML documents

You can of course also use the bar in pure HTML documents, as shown in the codepen. The syntax is:

<div class="progressbar" style="--duration: 2s;">
    <input type="checkbox" id="progress">
    <label for="progress">start</label>
</div>

Don’t forget to set a unique id both in the checkbox and the label and define the duration in the inline style.

Drawbacks

  • This is a bit of a hack as it is not accessible to non-visual users and abuses checkboxes to keep it CSS only. It is keyboard accessible though.
  • In a better world, I’d have used an HTML `progress` element and styled that one…

Share on Mastodon (needs instance)

Share on BlueSky

Newsletter

Check out the Dev Digest Newsletter I write every week for WeAreDevelopers. Latest issues:

Don't stop thinking, AI Slop vs. OSS Security, rolling your own S3 Despite AI you still need to think, Bitter lessons from building AI products,  AI Slop vs. OSS security and pointer pointer…
200: Building for the web, what's left after rm -rf & 🌊🐴 vs AI What remains after you do a rm -rf? Why do LLMs know about a seahorse emoji? What image formats should you use? How private is your car?
Word is Doomed, Flawed LLM benchmarks, hard sorting and CSS mistakes Spot LLM benchmark flaws, learn why sorting is hard, how to run Doom in Word and how to say "no" like a manager.
30 years of JS, Browser AI, how attackers use GenAI, whistling code Learn how to use AI in your browser and not on the cloud, why AI makes different mistakes than humans and go and whistle up some code!
197: Dunning-Kruger steroids, state of cloud security, puppies>beer

My other work: