CSS Progress Button
A button that fills from left to right to show upload progress, set with one custom property.
<button class="btn-progress" style="--progress: 65%" aria-busy="true">Uploading… 65%</button>
.btn-progress {
--progress: 0%;
position: relative;
isolation: isolate;
overflow: hidden;
min-width: 220px;
padding: 14px 28px;
border: 0;
border-radius: 10px;
background: #1e3a8a;
color: #fff;
font: 600 16px/1 system-ui, sans-serif;
font-variant-numeric: tabular-nums;
cursor: pointer;
}
.btn-progress::before {
content: "";
position: absolute;
inset: 0;
z-index: -1;
width: var(--progress);
background: #2563eb;
transition: width 0.3s ease;
}
.btn-progress[aria-busy="true"] {
cursor: progress;
}
.btn-progress:focus-visible {
outline: 3px solid #2563eb;
outline-offset: 3px;
}
About this CSS Progress Button
This CSS Progress Button is 34 lines of pure CSS (0.6 KB) with no JavaScript and no dependencies. It uses transitions, keyboard focus styles and custom properties. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.
CSS features used
Customize it
Change these custom properties to restyle the progress button without touching the rest of the CSS:
| Property | Default |
|---|---|
--progress | 0% |
How to use this progress button
- Copy the HTML and paste it where you want the element to appear.
- Copy the CSS into your stylesheet, or inside a
<style>tag. - Keep the
.btn-progressclass name, or rename it in both places. Then tweak colors, sizes and timing to match your design. - Using React or Next.js? Change
classtoclassNamein the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).
Building with an AI tool?
“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.