Facebook Pixel

Progress Bar Types: Linear, Circular, and Stepped

Three types of progress bars. Here is how to build each one in JavaScript.

Progress Bar Types: Linear, Circular, and Stepped

Here are three types of progress bars and how to build each one.

1. Linear Progress Bar

<div class="progress-container"> <div class="progress-bar" id="linearBar"></div> </div>
function setLinear(percent) { document.getElementById("linearBar").style.width = percent + "%"; }
.progress-container { width: 100%; height: 20px; background: #e0e0e0; border-radius: 10px; overflow: hidden; } .progress-bar { height: 100%; background: #007bff; transition: width 0.3s ease; }

2. Circular Progress Bar

<svg width="120" height="120" viewBox="0 0 120 120"> <circle cx="60" cy="60" r="50" stroke="#e0e0e0" stroke-width="8" fill="none" /> <circle cx="60" cy="60" r="50" stroke="#007bff" stroke-width="8" fill="none" stroke-linecap="round" stroke-dasharray="314.16" stroke-dashoffset="314.16" id="circleBar" transform="rotate(-90 60 60)" /> </svg> <span id="circleText">0%</span>
function setCircular(percent) { const circumference = 2 * Math.PI * 50; const offset = circumference - (percent / 100) * circumference; document.getElementById("circleBar").style.strokeDashoffset = offset; document.getElementById("circleText").textContent = percent + "%"; }

3. Stepped Progress Bar

<div class="steps"> <div class="step active">1. Personal</div> <div class="step">2. Address</div> <div class="step">3. Payment</div> <div class="step">4. Done</div> </div>
function setStep(currentStep) { document.querySelectorAll(".step").forEach((step, index) => { step.classList.toggle("active", index <= currentStep); }); }
.steps { display: flex; gap: 4px; } .step { flex: 1; padding: 8px; text-align: center; background: #e0e0e0; color: #666; } .step.active { background: #007bff; color: white; }

When to Use Each

  • Linear: file upload, download progress, task completion.
  • Circular: loading states, countdown timers, dashboards.
  • Stepped: multi-step forms, checkout, onboarding.

The Takeaway

Three types: linear (width %, CSS transition), circular (SVG, stroke-dashoffset), and stepped (discrete steps with active class). Use linear for file uploads, circular for loading states, and stepped for multi-step forms. Each has a different use case.

Linear (horizontal bar with width %), circular (SVG ring with stroke-dashoffset), and stepped (discrete steps with active states). Also striped (animated stripes) for indeterminate progress.

Use two SVG circles. The background circle has a gray stroke. The progress circle has stroke-dasharray set to the circumference (2 * PI * radius) and stroke-dashoffset set to circumference - (percent/100 * circumference). Rotate -90 degrees.

Create step elements in a flex row. Toggle an 'active' class based on the current step: step.classList.toggle('active', index <= currentStep). Style .active with a different background color.

Use circular for loading states, countdown timers, and dashboards (compact, visual). Use linear for file uploads, downloads, and task completion (shows proportion clearly). Use stepped for multi-step forms.

offset = circumference - (percent / 100) * circumference. Where circumference = 2 * Math.PI * radius. At 0%, offset = circumference (no fill). At 100%, offset = 0 (full fill).

Ready to master React completely?

Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course to dive deeper with high-quality video tutorials, solve interview questions, and a premium community.

Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.