Tab Form Progress Indicator Implementation
Show users how far they are in the form. Here is how to implement a progress indicator.
Tab Form Progress Indicator Implementation
A progress indicator shows users how far they are in the form. Here is how to implement it.
Linear Progress
function updateProgress() { const percent = ((currentStep + 1) / steps.length) * 100; document.getElementById("progressFill").style.width = percent + "%"; }
<div class="progress-container"> <div class="progress-fill" id="progressFill"></div> </div>
Stepped Progress
<div class="step-indicator"> <div class="step-dot completed">1</div> <div class="step-line completed"></div> <div class="step-dot active">2</div> <div class="step-line"></div> <div class="step-dot">3</div> </div>
function updateStepIndicator() { document.querySelectorAll(".step-dot").forEach((dot, i) => { dot.classList.remove("active", "completed"); if (i < currentStep) dot.classList.add("completed"); if (i === currentStep) dot.classList.add("active"); }); document.querySelectorAll(".step-line").forEach((line, i) => { line.classList.toggle("completed", i < currentStep); }); }
CSS
.step-indicator { display: flex; align-items: center; gap: 0; } .step-dot { width: 30px; height: 30px; border-radius: 50%; background: #e0e0e0; display: flex; align-items: center; justify-content: center; font-weight: bold; } .step-dot.active { background: #007bff; color: white; } .step-dot.completed { background: #44aa44; color: white; } .step-line { flex: 1; height: 2px; background: #e0e0e0; min-width: 40px; } .step-line.completed { background: #44aa44; }
The Takeaway
Progress indicator: linear (percentage bar, ((currentStep + 1) / steps.length) * 100) or stepped (dots with completed/active states and connecting lines). Update on every step change. Completed steps are green, active is blue, future steps are gray. This gives users a clear sense of progress.
Two options: linear (a progress bar with width = ((currentStep + 1) / steps.length) * 100) or stepped (dots with completed/active states connected by lines). Update on every step change. Completed steps are green, active is blue.
Create dots for each step. For each dot: add 'completed' class if index < currentStep, 'active' class if index === currentStep. For connecting lines: add 'completed' class if index < currentStep. Update on every step change.
Dots: circular (border-radius: 50%), fixed size, centered text. Lines: flex: 1, thin height (2px). Completed: green background. Active: blue background. Default: gray background. Use display: flex on the container with align-items: center.
((currentStep + 1) / steps.length) * 100. For example, step 2 of 4: ((2 + 1) / 4) * 100 = 75%. Wait, step 2 of 4 (0-indexed): ((1 + 1) / 4) * 100 = 50%. Use currentStep + 1 because steps are 0-indexed.
Yes, but only to completed steps. Clicking a completed step lets the user review or edit previous data. Do not allow jumping forward to unvalidated steps. Validate all intermediate steps before allowing forward navigation.
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.
Master React
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course.

