Tailwind Progress Bars: 5 Progress Bars in React and HTML
Updated 2026-10-28. 5 progress bars.
In Tailwind, draw a progress bar as a rounded track with a coloured fill inside it, and set the fill width or a scaleX transform from your value. Mark the track role progressbar with aria-valuenow, aria-valuemin and aria-valuemax and a label, so assistive technology hears the number the bar shows.
Use the labelled linear bar for anything with a known percentage, such as profile completion or storage used. The striped bar adds motion to say that work is still happening, which suits a long export or install where the number moves slowly. The segmented version is for multi-step flows like checkout, where people care which step they are on more than the exact percentage.
A circular ring fits in cards and dashboards where a bar would be too wide, and it shows the number in its centre. The upload list gives each file its own bar, status and cancel button, which is what people expect when they drop several photos or documents at once. Every piece reads its value from one variable, so connecting it to real progress is a matter of updating that number.
Compare them
| Variant | Built with | Size (gzipped) | Running cost | Browser support |
|---|---|---|---|---|
| Labelled Linear Progress Bar With Value | CSS only | 1.6 KB | One transform transition per update; no timers or frame loops. | All current browsers |
| Circular SVG Progress Ring With Percentage | CSS only | 1.8 KB | One stroke-dashoffset transition on a single SVG circle per change. | All current browsers |
| File Upload List With Per File Progress Bars | CSS and a small script | 2.1 KB | A 400 ms demo timer and one scaleX transition per file bar. | All current browsers |
| Segmented Step Progress Bar | CSS only | 1.8 KB | Four static segments that swap a background colour per step. | All current browsers |
| Striped Animated Progress Bar | CSS only | 1.6 KB | Stripes slide by transform on one layer; the fill width changes once per update. | All current browsers |
Labelled Linear Progress Bar With Value
A setup checklist card for a florist's new site. A title and a bold percentage sit above a thin blue bar, a line underneath says 3 of 5 steps done, and the steps below tick off as the bar fills. Two buttons move it forward and back so you can watch the fill ease into place. The card keeps its layout at phone width with the buttons side by side.
<section class="lpb">
<div class="lpb-card">
<div class="lpb-head">
<h2 id="lpb-label" class="lpb-title">Site setup</h2>
<span class="lpb-pct" aria-hidden="true">60%</span>
</div>
<p class="lpb-sub"><span class="lpb-done">3</span> of 5 steps done for Bramble & Oak Florists</p>
<div class="lpb-track" role="progressbar" aria-labelledby="lpb-label" aria-valuemin="0" aria-valuemax="100" aria-valuenow="60" aria-valuetext="60 percent, 3 of 5 steps">
<div class="lpb-fill"></div>
</div>
<ol class="lpb-steps">
<li>Add your logo</li>
<li>Pick a colour theme</li>
<li>Write the About page</li>
<li>Connect a domain</li>
<li>Publish</li>
</ol>
<div class="lpb-actions">
<button type="button" class="lpb-next">Mark next step done</button>
<button type="button" class="lpb-undo">Undo</button>
</div>
</div>
</section>
<style>
.lpb { --lpb-accent: #2563eb; background: #fff; padding: 64px 16px; font-family: ui-sans-serif, system-ui, sans-serif; color: #0f172a; }
.lpb-card { max-width: 32rem; margin: 0 auto; padding: 28px; border: 1px solid #e2e8f0; border-radius: 16px; }
.lpb-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.lpb-title { margin: 0; font-size: 16px; font-weight: 600; }
.lpb-pct { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lpb-sub { margin: 4px 0 0; font-size: 14px; color: #475569; }
.lpb-track { height: 10px; margin-top: 16px; overflow: hidden; border-radius: 999px; background: #f1f5f9; }
/* scaleX moves the fill on the compositor instead of changing its width */
.lpb-fill { width: 100%; height: 100%; border-radius: 999px; background: var(--lpb-accent); transform: scaleX(.6); transform-origin: left; transition: transform .5s cubic-bezier(.2,.8,.2,1); }
.lpb-steps { margin: 24px 0 0; padding: 0; list-style: none; }
.lpb-steps li { position: relative; display: flex; align-items: center; height: 36px; padding-left: 32px; font-size: 14px; color: #334155; }
.lpb-steps li::before { content: ""; position: absolute; left: 0; width: 16px; height: 16px; border: 2px solid #cbd5e1; border-radius: 50%; }
.lpb-steps li[data-done] { color: #64748b; text-decoration: line-through; }
.lpb-steps li[data-done]::before { border-color: var(--lpb-accent); background: var(--lpb-accent); }
.lpb-steps li[data-next] { font-weight: 500; color: #0f172a; }
.lpb-actions { display: flex; gap: 8px; margin-top: 24px; }
.lpb-actions button { height: 40px; padding: 0 16px; border-radius: 8px; font: 500 14px ui-sans-serif, system-ui, sans-serif; cursor: pointer; }
.lpb-next { border: 0; background: #0f172a; color: #fff; }
.lpb-undo { border: 1px solid #cbd5e1; background: #fff; color: #1e293b; }
.lpb-actions button:disabled { background: #e2e8f0; color: #334155; cursor: default; }
.lpb-actions button:focus-visible { outline: 2px solid var(--lpb-accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .lpb-fill { transition: none; } }
</style>
<script>
(function () {
var root = document.querySelector(".lpb");
if (!root) return;
var steps = root.querySelectorAll(".lpb-steps li"), total = steps.length, done = 3;
var track = root.querySelector(".lpb-track"), fill = root.querySelector(".lpb-fill");
var pctEl = root.querySelector(".lpb-pct"), doneEl = root.querySelector(".lpb-done");
var next = root.querySelector(".lpb-next"), undo = root.querySelector(".lpb-undo");
function render() {
var pct = Math.round(done / total * 100);
fill.style.transform = "scaleX(" + done / total + ")";
track.setAttribute("aria-valuenow", pct);
track.setAttribute("aria-valuetext", pct + " percent, " + done + " of " + total + " steps");
pctEl.textContent = pct + "%"; doneEl.textContent = done;
steps.forEach(function (li, i) { li.toggleAttribute("data-done", i < done); li.toggleAttribute("data-next", i === done); });
next.disabled = done >= total; undo.disabled = done === 0;
}
next.addEventListener("click", function () { done++; render(); });
undo.addEventListener("click", function () { done--; render(); });
render();
})();
</script>
With reduced motion: The fill jumps to each new value instead of easing.
Running cost: One transform transition per update; no timers or frame loops.
- Edit the `STEPS` array; the percentage and bar follow its length automatically.
- Change the fill colour with `bg-blue-600`, or `--lpb-accent` in the plain CSS, and the track with `bg-slate-100`.
- Make the bar thicker or thinner with `h-2.5` on the track, for example `h-1.5` for a hairline or `h-4` for a chunky bar.
- Lengthen or shorten the easing with `duration-500`; keep it under about 600 ms so updates do not lag.
Full page for Labelled Linear Progress Bar With Value
Circular SVG Progress Ring With Percentage
A weekly fitness goal card on deep teal: a cyan ring sweeps round from the top to 69 percent with the number and 27.4 / 40 km in its centre. A two-option switch below changes the goal to active days, and the ring empties and refills to the new value. The ring is a fixed 192 pixels, so it fits a phone card unchanged.
<section class="cpr">
<div class="cpr-card">
<div class="cpr-head">
<h2 id="cpr-label" class="cpr-title">This week’s distance</h2>
<span class="cpr-date">Mon 26 Oct to Sun 1 Nov</span>
</div>
<div class="cpr-ring" role="progressbar" aria-labelledby="cpr-label" aria-valuemin="0" aria-valuemax="100" aria-valuenow="69" aria-valuetext="27.4 of 40 km, 69 percent">
<svg viewBox="0 0 120 120" aria-hidden="true">
<circle class="cpr-track" cx="60" cy="60" r="52"/>
<circle class="cpr-fill" cx="60" cy="60" r="52"/>
</svg>
<div class="cpr-center" aria-hidden="true">
<span class="cpr-pct">69%</span>
<span class="cpr-of">27.4 / 40 km</span>
</div>
</div>
<div class="cpr-tabs" role="group" aria-label="Choose goal">
<button type="button" aria-pressed="true" data-label="distance" data-done="27.4" data-target="40" data-unit="km">Distance</button>
<button type="button" aria-pressed="false" data-label="active days" data-done="4" data-target="5" data-unit="days">Active days</button>
</div>
</div>
</section>
<style>
/* the circle's circumference is 2 x pi x 52, about 326.73 */
.cpr { --cpr-c: 326.73; --cpr-accent: #22d3ee; background: linear-gradient(135deg, #083344, #020617); padding: 64px 16px; font-family: ui-sans-serif, system-ui, sans-serif; color: #fff; }
.cpr-card { max-width: 24rem; margin: 0 auto; padding: 28px; border-radius: 24px; background: rgba(255,255,255,.04); box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); }
.cpr-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.cpr-title { margin: 0; font-size: 16px; font-weight: 600; }
.cpr-date { font-size: 12px; color: #a5f3fc; }
.cpr-ring { position: relative; width: 192px; height: 192px; margin: 24px auto 0; }
.cpr-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.cpr-ring circle { fill: none; stroke-width: 10; }
.cpr-track { stroke: rgba(255,255,255,.08); }
.cpr-fill { stroke: var(--cpr-accent); stroke-linecap: round; stroke-dasharray: var(--cpr-c); stroke-dashoffset: var(--cpr-c); transition: stroke-dashoffset 1s cubic-bezier(.2,.8,.2,1); }
.cpr-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.cpr-pct { font-size: 36px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.cpr-of { margin-top: 4px; font-size: 14px; color: #cbd5e1; }
.cpr-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 24px; padding: 4px; border-radius: 999px; background: rgba(255,255,255,.05); }
.cpr-tabs button { height: 40px; border: 0; border-radius: 999px; background: none; color: #e2e8f0; font: 500 14px ui-sans-serif, system-ui, sans-serif; cursor: pointer; }
.cpr-tabs button[aria-pressed="true"] { background: #67e8f9; color: #020617; }
.cpr-tabs button:focus-visible { outline: 2px solid #67e8f9; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .cpr-fill { transition: none; } }
</style>
<script>
(function () {
var root = document.querySelector(".cpr");
if (!root) return;
var C = 2 * Math.PI * 52;
var ring = root.querySelector(".cpr-ring"), fill = root.querySelector(".cpr-fill"), tabs = root.querySelectorAll(".cpr-tabs button");
function show(btn) {
var done = Number(btn.getAttribute("data-done")), target = Number(btn.getAttribute("data-target")), unit = btn.getAttribute("data-unit");
var pct = Math.round(done / target * 100);
tabs.forEach(function (t) { t.setAttribute("aria-pressed", t === btn); });
root.querySelector(".cpr-title").textContent = "This week’s " + btn.getAttribute("data-label");
root.querySelector(".cpr-pct").textContent = pct + "%";
root.querySelector(".cpr-of").textContent = done + " / " + target + " " + unit;
ring.setAttribute("aria-valuenow", pct);
ring.setAttribute("aria-valuetext", done + " of " + target + " " + unit + ", " + pct + " percent");
fill.style.strokeDashoffset = C;
/* wait a frame so the ring empties, then let the transition fill it */
requestAnimationFrame(function () { requestAnimationFrame(function () { fill.style.strokeDashoffset = C * (1 - Math.min(pct, 100) / 100); }); });
}
tabs.forEach(function (t) { t.addEventListener("click", function () { show(t); }); });
/* start filling once the card is on screen */
var io = new IntersectionObserver(function (e) { if (e[0].isIntersecting) { show(tabs[0]); io.disconnect(); } });
io.observe(root);
})();
</script>
With reduced motion: The ring shows its final arc at once with no sweep.
Running cost: One stroke-dashoffset transition on a single SVG circle per change.
- Change `R` and `strokeWidth` together; keep R plus half the stroke under 60 so the ring stays inside the 120 unit viewBox.
- Edit the `GOALS` array, or the data attributes on each button in the plain version, for your own metrics.
- Set `--cpr-c` to two times pi times your radius if you change it in the CSS version.
File Upload List With Per File Progress Bars
An upload panel for a renovation project with one row per file: a small type badge, the name, megabytes sent so far and a thin bar of its own. Bars turn green with a tick when a file lands, and each running upload has a cancel button that greys its row out. A summary line at the top says how many uploads are still going.
<section class="ful">
<div class="ful-card">
<div class="ful-head">
<h2 class="ful-title">Project photos</h2>
<p class="ful-status" aria-live="polite"></p>
</div>
<ul class="ful-list">
<li data-size="4.2" data-pct="100">
<span class="ful-type" aria-hidden="true">jpg</span>
<div class="ful-main">
<div class="ful-row"><span class="ful-name" id="ful-f1">kitchen-before.jpg</span><span class="ful-size"></span></div>
<div class="ful-track" role="progressbar" aria-labelledby="ful-f1" aria-valuemin="0" aria-valuemax="100"><div class="ful-fill"></div></div>
</div>
<button type="button" class="ful-x" aria-label="Cancel upload of kitchen-before.jpg">×</button>
<span class="ful-ok" role="img" aria-label="Uploaded"></span>
</li>
<li data-size="6.8" data-pct="64">
<span class="ful-type" aria-hidden="true">jpg</span>
<div class="ful-main">
<div class="ful-row"><span class="ful-name" id="ful-f2">kitchen-after-wide.jpg</span><span class="ful-size"></span></div>
<div class="ful-track" role="progressbar" aria-labelledby="ful-f2" aria-valuemin="0" aria-valuemax="100"><div class="ful-fill"></div></div>
</div>
<button type="button" class="ful-x" aria-label="Cancel upload of kitchen-after-wide.jpg">×</button>
<span class="ful-ok" role="img" aria-label="Uploaded"></span>
</li>
<li data-size="1.9" data-pct="22">
<span class="ful-type ful-pdf" aria-hidden="true">pdf</span>
<div class="ful-main">
<div class="ful-row"><span class="ful-name" id="ful-f3">floor-plan-v3.pdf</span><span class="ful-size"></span></div>
<div class="ful-track" role="progressbar" aria-labelledby="ful-f3" aria-valuemin="0" aria-valuemax="100"><div class="ful-fill"></div></div>
</div>
<button type="button" class="ful-x" aria-label="Cancel upload of floor-plan-v3.pdf">×</button>
<span class="ful-ok" role="img" aria-label="Uploaded"></span>
</li>
</ul>
</div>
</section>
<style>
.ful { --ful-accent: #4f46e5; --ful-done: #10b981; background: #f8fafc; padding: 64px 16px; font-family: ui-sans-serif, system-ui, sans-serif; color: #0f172a; }
.ful-card { max-width: 36rem; margin: 0 auto; padding: 24px; background: #fff; border-radius: 16px; box-shadow: 0 0 0 1px #e2e8f0, 0 1px 2px rgba(0,0,0,.05); }
.ful-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ful-title { margin: 0; font-size: 16px; font-weight: 600; }
.ful-status { margin: 0; font-size: 14px; color: #475569; }
.ful-list { margin: 16px 0 0; padding: 0; list-style: none; }
.ful-list li { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid #f1f5f9; }
.ful-list li:first-child { border-top: 0; }
.ful-type { display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; border-radius: 8px; background: #eef2ff; color: #4338ca; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.ful-pdf { background: #fff1f2; color: #be123c; }
.ful-main { flex: 1; min-width: 0; }
.ful-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.ful-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.ful-size { flex-shrink: 0; font-size: 12px; color: #475569; font-variant-numeric: tabular-nums; }
.ful-track { height: 6px; margin-top: 8px; overflow: hidden; border-radius: 999px; background: #f1f5f9; }
.ful-fill { width: 100%; height: 100%; border-radius: 999px; background: var(--ful-accent); transform: scaleX(0); transform-origin: left; transition: transform .3s; }
[data-state="done"] .ful-fill { background: var(--ful-done); }
[data-state="cancelled"] .ful-fill { background: #cbd5e1; }
.ful-x { width: 40px; height: 40px; flex-shrink: 0; border: 0; border-radius: 8px; background: none; color: #475569; font-size: 20px; cursor: pointer; }
.ful-x:hover { background: #f1f5f9; }
.ful-x:focus-visible { outline: 2px solid var(--ful-accent); }
.ful-ok { display: none; width: 40px; height: 40px; flex-shrink: 0; background: no-repeat center / 20px; }
[data-state="done"] .ful-ok { display: block; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='9' fill='%2310b981'/%3E%3Cpath d='M6 10.4l2.6 2.6L14 7.6' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
[data-state="cancelled"] .ful-ok { display: block; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='9' fill='%23cbd5e1'/%3E%3Cpath d='M6.5 10h7' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
[data-state="done"] .ful-x, [data-state="cancelled"] .ful-x { display: none; }
@media (prefers-reduced-motion: reduce) { .ful-fill { transition: none; } }
</style>
<script>
(function () {
var root = document.querySelector(".ful");
if (!root) return;
var rows = [].slice.call(root.querySelectorAll(".ful-list li")), status = root.querySelector(".ful-status");
var start = rows.map(function (li) { return Number(li.getAttribute("data-pct")); });
function render(li) {
var pct = Number(li.getAttribute("data-pct")), size = Number(li.getAttribute("data-size")), state = li.getAttribute("data-state");
li.querySelector(".ful-fill").style.transform = "scaleX(" + pct / 100 + ")";
li.querySelector(".ful-track").setAttribute("aria-valuenow", pct);
li.querySelector(".ful-size").textContent = state === "done" ? size + " MB" : state === "cancelled" ? "Cancelled" : (size * pct / 100).toFixed(1) + " of " + size + " MB";
li.querySelector(".ful-ok").setAttribute("aria-label", state === "cancelled" ? "Cancelled" : "Uploaded");
}
function setState(li, pct) { li.setAttribute("data-pct", pct); li.setAttribute("data-state", pct >= 100 ? "done" : "uploading"); }
function summary() {
var busy = rows.filter(function (li) { return li.getAttribute("data-state") === "uploading"; }).length;
status.textContent = busy ? "Uploading " + busy + " of " + rows.length : "All uploads finished";
return busy;
}
rows.forEach(function (li, i) {
setState(li, start[i]); render(li);
li.querySelector(".ful-x").addEventListener("click", function () { li.setAttribute("data-state", "cancelled"); render(li); summary(); });
});
summary();
/* demo only: replace with progress events from your upload request */
setInterval(function () {
if (!summary()) { rows.forEach(function (li, i) { setState(li, start[i]); render(li); }); summary(); return; }
rows.forEach(function (li) {
if (li.getAttribute("data-state") !== "uploading") return;
var size = Number(li.getAttribute("data-size"));
setState(li, Math.min(100, Number(li.getAttribute("data-pct")) + Math.round(9 / size + 2)));
render(li);
});
summary();
}, 400);
})();
</script>
With reduced motion: Each bar steps to its new value with no easing between updates.
Running cost: A 400 ms demo timer and one scaleX transition per file bar.
- Drop the demo `setInterval` and update each item's `pct` from the progress event of your upload request.
- Recolour running, finished and cancelled bars through `bg-indigo-600`, `bg-emerald-500` and `bg-slate-300`.
- Add a retry button in the cancelled state by rendering it where the grey cancelled icon sits.
Segmented Step Progress Bar
A coffee shop checkout split into four separate segments rather than one long bar. Finished steps are solid olive with a tick, the current one is half filled in lime to show it is in progress, and later ones stay grey. The heading names the step in words, and Back and Continue buttons walk through the flow so the segments update.
<section class="ssp">
<div class="ssp-wrap">
<p class="ssp-kicker">Checkout, Wildgrain Coffee</p>
<h2 class="ssp-title">Step 3 of 4: Payment</h2>
<nav aria-label="Checkout progress">
<ol class="ssp-steps">
<li><span class="ssp-bar"></span><span class="ssp-name">Bag<span class="ssp-sr"></span></span></li>
<li><span class="ssp-bar"></span><span class="ssp-name">Delivery<span class="ssp-sr"></span></span></li>
<li><span class="ssp-bar"></span><span class="ssp-name">Payment<span class="ssp-sr"></span></span></li>
<li><span class="ssp-bar"></span><span class="ssp-name">Review<span class="ssp-sr"></span></span></li>
</ol>
</nav>
<div class="ssp-panel"><p>Card ending 0042, billing address same as delivery.</p></div>
<div class="ssp-actions">
<button type="button" class="ssp-back">Back</button>
<button type="button" class="ssp-next">Review order</button>
</div>
</div>
</section>
<style>
.ssp { --ssp-done: #4d7c0f; --ssp-now: #84cc16; background: #f6f7f2; padding: 64px 16px; font-family: ui-sans-serif, system-ui, sans-serif; color: #1c1917; }
.ssp-wrap { max-width: 42rem; margin: 0 auto; }
.ssp-kicker { margin: 0; font-size: 14px; font-weight: 500; color: #365314; }
.ssp-title { margin: 4px 0 0; font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.ssp-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 24px 0 0; padding: 0; list-style: none; }
.ssp-bar { display: block; height: 8px; border-radius: 999px; background: #d6d3d1; transition: background-color .3s; }
[data-state="done"] .ssp-bar { background: var(--ssp-done); }
/* the current segment is half filled with a lighter green */
[data-state="now"] .ssp-bar { background: linear-gradient(90deg, var(--ssp-now) 50%, #d6d3d1 50%); }
.ssp-name { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12px; font-weight: 500; color: #57534e; }
[data-state="done"] .ssp-name, [data-state="now"] .ssp-name { color: #1c1917; }
[data-state="done"] .ssp-name::before { content: ""; width: 14px; height: 14px; flex-shrink: 0; border-radius: 50%; background: var(--ssp-done) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M5 8.3l2 2 4-4.3' fill='none' stroke='white' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") center / 14px no-repeat; }
@media (min-width: 640px) { .ssp-name { font-size: 14px; } }
.ssp-panel { margin-top: 32px; padding: 20px; border: 1px solid #e7e5e4; border-radius: 12px; background: #fff; font-size: 14px; color: #44403c; }
.ssp-panel p { margin: 0; }
.ssp-actions { display: flex; justify-content: space-between; margin-top: 24px; }
.ssp-actions button { height: 44px; padding: 0 22px; border-radius: 999px; font: 500 14px ui-sans-serif, system-ui, sans-serif; cursor: pointer; }
.ssp-back { border: 1px solid #d6d3d1; background: #fff; color: #292524; }
.ssp-next { border: 0; background: #3f6212; color: #fff; font-weight: 600; }
.ssp-actions button:disabled { background: #d6d3d1; color: #44403c; cursor: default; }
.ssp-actions button:focus-visible { outline: 2px solid var(--ssp-done); outline-offset: 2px; }
.ssp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: reduce) { .ssp-bar { transition: none; } }
</style>
<script>
(function () {
var root = document.querySelector(".ssp");
if (!root) return;
var items = root.querySelectorAll(".ssp-steps li"), step = 2, n = items.length;
var title = root.querySelector(".ssp-title"), panel = root.querySelector(".ssp-panel p");
var back = root.querySelector(".ssp-back"), next = root.querySelector(".ssp-next");
function name(i) { return items[i].querySelector(".ssp-name").firstChild.textContent; }
function render() {
items.forEach(function (li, i) {
var s = i < step ? "done" : i === step ? "now" : "next";
li.setAttribute("data-state", s);
if (s === "now") li.setAttribute("aria-current", "step"); else li.removeAttribute("aria-current");
li.querySelector(".ssp-sr").textContent = s === "done" ? ", completed" : s === "now" ? ", current step" : "";
});
title.textContent = "Step " + (step + 1) + " of " + n + ": " + name(step);
panel.textContent = step === 2 ? "Card ending 0042, billing address same as delivery." : "Details for " + name(step).toLowerCase() + " go here.";
back.disabled = step === 0; next.disabled = step === n - 1;
next.textContent = step === n - 2 ? "Review order" : "Continue";
}
back.addEventListener("click", function () { step--; render(); });
next.addEventListener("click", function () { step++; render(); });
render();
})();
</script>
With reduced motion: Segments change colour instantly when you move between steps.
Running cost: Four static segments that swap a background colour per step.
- Change `STEPS` for your own flow; the grid uses `grid-cols-4`, so update that (or `repeat(4, 1fr)`) to match the count.
- Use a different current step fill by editing `bg-lime-500`, or `--ssp-now` in the plain CSS.
- Hide the step names on very small screens with `sr-only sm:not-sr-only` if your labels are long.
Striped Animated Progress Bar
An export job on a dark panel: an amber bar with diagonal stripes that keep sliding while the work runs, a large monospace percentage, a time estimate and a file count. The stripes say that something is still happening even when the number moves slowly, and they disappear when the job finishes. In the preview a timer climbs and loops so the motion is visible.
<section class="spb">
<div class="spb-card">
<div class="spb-head">
<div>
<h2 id="spb-label" class="spb-title">Exporting season archive</h2>
<p class="spb-sub">1,240 photos to a ZIP, about <span class="spb-min">8</span> min left</p>
</div>
<span class="spb-pct" aria-hidden="true">38%</span>
</div>
<div class="spb-track" role="progressbar" aria-labelledby="spb-label" aria-valuemin="0" aria-valuemax="100" aria-valuenow="38">
<div class="spb-fill" style="width: 38%"></div>
</div>
<div class="spb-foot">
<span class="spb-count">471 of 1,240 files</span>
<button type="button" class="spb-cancel">Cancel</button>
</div>
</div>
</section>
<style>
.spb { --spb-fill: #fbbf24; background: #171717; padding: 64px 16px; font-family: ui-sans-serif, system-ui, sans-serif; color: #fff; }
.spb-card { max-width: 36rem; margin: 0 auto; padding: 28px; background: #262626; border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); }
.spb-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.spb-title { margin: 0; font-size: 16px; font-weight: 600; }
.spb-sub { margin: 2px 0 0; font-size: 14px; color: #d4d4d4; }
.spb-pct { font: 600 24px ui-monospace, Menlo, monospace; color: #fcd34d; font-variant-numeric: tabular-nums; }
.spb-track { height: 20px; margin-top: 20px; overflow: hidden; border-radius: 6px; background: #0a0a0a; box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); }
.spb-fill { position: relative; height: 100%; overflow: hidden; border-radius: 6px; background: var(--spb-fill); transition: width .7s linear; }
/* the stripes live on a wider layer that slides one stripe width and repeats */
.spb-fill::after { content: ""; position: absolute; top: 0; bottom: 0; left: -28px; right: 0; background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,.22) 0 10px, transparent 10px 20px); animation: spb-slide .9s linear infinite; }
.spb[data-done] .spb-fill::after, .spb[data-off] .spb-fill::after { animation-play-state: paused; }
.spb[data-done] .spb-fill::after { display: none; }
@keyframes spb-slide { to { transform: translateX(28px); } }
.spb-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; font-size: 14px; color: #d4d4d4; }
.spb-cancel { height: 40px; padding: 0 12px; border: 0; border-radius: 6px; background: none; color: #e5e5e5; font: 500 14px ui-sans-serif, system-ui, sans-serif; cursor: pointer; }
.spb-cancel:hover { background: rgba(255,255,255,.1); }
.spb-cancel:focus-visible { outline: 2px solid #fcd34d; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .spb-fill { transition: none; } .spb-fill::after { animation: none; } }
</style>
<script>
(function () {
var root = document.querySelector(".spb");
if (!root) return;
/* demo timer; call setProgress() from your real upload or export events instead */
var pct = 38, timer = setInterval(function () { setProgress(pct >= 100 ? 12 : Math.min(100, pct + 4)); }, 700);
var track = root.querySelector(".spb-track"), fill = root.querySelector(".spb-fill");
function setProgress(v) {
pct = v;
fill.style.width = v + "%";
track.setAttribute("aria-valuenow", v);
root.querySelector(".spb-pct").textContent = v + "%";
root.querySelector(".spb-min").textContent = Math.max(1, Math.round((100 - v) / 8));
root.querySelector(".spb-count").textContent = v >= 100 ? "Archive ready" : Math.round(1240 * v / 100) + " of 1,240 files";
root.toggleAttribute("data-done", v >= 100);
}
root.querySelector(".spb-cancel").addEventListener("click", function () { clearInterval(timer); root.querySelector(".spb-count").textContent = "Export cancelled"; root.setAttribute("data-off", ""); });
new IntersectionObserver(function (e) { if (!root.hasAttribute("data-done")) root.toggleAttribute("data-off", !e[0].isIntersecting); }).observe(root);
})();
</script>
With reduced motion: The stripes stand still and the fill steps to each value without easing.
Running cost: Stripes slide by transform on one layer; the fill width changes once per update.
- Remove the demo `setInterval` and set `pct` from your own export, upload or install events.
- Change the stripe width in the gradient stops (10px and 20px) and keep the slide distance at the diagonal repeat, here 28px.
- Swap amber for another fill with `bg-amber-400`, or `--spb-fill` in CSS; white stripes at 22 percent opacity work on most mid-tone colours.
Performance notes
Changing the width of a fill on every update makes the browser recalculate layout for that element. For bars that update often, the pieces here scale the fill along the x axis instead, which the browser can do on the compositor. The circular ring animates stroke-dashoffset on a single SVG circle, which only repaints that small area.
The stripe animation moves a repeating gradient with a transform on a layer inside the fill, so it never repaints the whole page, and it stops for reduced motion. Demo timers that move the bars in the preview are small intervals that you would replace with your real progress events; they are cleared when the component unmounts.
Questions
How do I make a progress bar in Tailwind?
Use a div with a fixed height, full width, rounded corners and a light background as the track, and a child div with the same height and a strong colour as the fill. Set the fill's width with a style value from your percentage, or scale it with a transform for smoother updates.
Should I use the HTML progress element?
The native progress element is accessible by default and works without script, but it is awkward to style the same way in every browser. A div with role progressbar and the aria-value attributes gives you full control over looks with the same meaning for screen readers.
How do I show progress when I do not know the total?
Use an indeterminate state: leave out aria-valuenow and show a moving band or stripes instead of a fill width. Switch to a real value as soon as you know the total, because a number is more reassuring than motion.
How do I animate a progress bar smoothly?
Add a transition on transform or width of about 300 milliseconds so each update eases into place. Avoid long transitions on frequent updates, or the bar will lag behind the real value.
How do I build a circular progress bar?
Draw two SVG circles with the same radius, a pale one as the track and a coloured one on top. Set the top circle's stroke-dasharray to its circumference and its stroke-dashoffset to the circumference times the remaining fraction, then rotate the SVG so it starts at the top.
Also in the gallery: Percentage Counter With Progress Ring, Booking Steps Push Up With a Filling Progress Bar, 117 CSS Loaders and Spinners You Can Copy.
More collections: HTML Forms With CSS: 5 Styled Forms to Copy, OTP Input Field in HTML and CSS: 5 Verification Code Inputs, React Tag Input: 5 Chip Inputs With Real Keyboard Support. All loaders. Build your site free to have a full site built around them.
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App