<html><head><base href="https://webbox-ai.vercel.app/multi-step-progress-bar/" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Enhanced Multi-step Progress Bar</title>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"
integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
font-family: Arial, sans-serif;
background-color: #f0f4f8;
flex-direction: column;
padding: 20px;
}
h1 {
margin-bottom: 40px;
color: #2d3748;
text-align: center;
}
.container {
background-color: #ffffff;
border-radius: 8px;
padding: 30px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.progress-container {
display: flex;
justify-content: space-between;
position: relative;
margin-bottom: 40px;
max-width: 100%;
width: 350px;
}
.progress-container::before {
content: "";
background-color: #e2e8f0;
position: absolute;
top: 50%;
left: 0;
transform: translateY(-50%);
height: 4px;
width: 100%;
z-index: 1;
}
.progress {
background-color: #4299e1;
position: absolute;
top: 50%;
left: 0;
transform: translateY(-50%);
height: 4px;
width: 0%;
z-index: 2;
transition: width 0.3s ease;
}
.icon-wrapper {
background-color: #e2e8f0;
border-radius: 50%;
height: 40px;
width: 40px;
display: flex;
align-items: center;
justify-content: center;
border: 4px solid #fff;
z-index: 3;
transition: all 0.3s ease;
}
.icon-wrapper.active {
background-color: #4299e1;
}
.icon-wrapper i {
color: #718096;
font-size: 20px;
transition: all 0.3s ease;
}
.icon-wrapper.active i {
color: #fff;
}
.icon-wrapper .label {
position: absolute;
font-size: 14px;
bottom: -25px;
font-weight: bold;
color: #718096;
transition: color 0.3s ease;
}
.icon-wrapper.active .label {
color: #4299e1;
}
.button-container {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
.prev-btn,
.next-btn {
font-size: 16px;
padding: 10px 20px;
background-color: #4299e1;
color: #fff;
border-radius: 5px;
border: none;
cursor: pointer;
transition: background-color 0.3s ease, transform 0.1s ease;
}
.prev-btn:hover,
.next-btn:hover {
background-color: #3182ce;
}
.prev-btn:active,
.next-btn:active {
transform: translateY(1px);
}
.prev-btn:disabled,
.next-btn:disabled {
background-color: #a0aec0;
cursor: not-allowed;
}
@media (max-width: 480px) {
.progress-container {
width: 280px;
}
.icon-wrapper {
height: 30px;
width: 30px;
}
.icon-wrapper i {
font-size: 16px;
}
.icon-wrapper .label {
font-size: 12px;
bottom: -20px;
}
}
</style>
</head>
<body>
<h1>Multi-step Progress Bar</h1>
<div class="container">
<div class="progress-container">
<div class="progress"></div>
<div class="icon-wrapper active">
<i class="fa-brands fa-facebook"></i>
<p class="label">Facebook</p>
</div>
<div class="icon-wrapper">
<i class="fa-brands fa-linkedin"></i>
<p class="label">LinkedIn</p>
</div>
<div class="icon-wrapper">
<i class="fa-brands fa-instagram"></i>
<p class="label">Instagram</p>
</div>
<div class="icon-wrapper">
<i class="fa-brands fa-twitter"></i>
<p class="label">Twitter</p>
</div>
</div>
<div class="button-container">
<button class="prev-btn" disabled>Previous</button>
<button class="next-btn">Next</button>
</div>
</div>
<script>
const progress = document.querySelector(".progress");
const prevBtn = document.querySelector(".prev-btn");
const nextBtn = document.querySelector(".next-btn");
const iconsWrapper = document.querySelectorAll(".icon-wrapper");
let currentSelectedStep = 1;
nextBtn.addEventListener("click", () => {
if (currentSelectedStep < iconsWrapper.length) {
currentSelectedStep++;
handleUpdateStep();
}
});
prevBtn.addEventListener("click", () => {
if (currentSelectedStep > 1) {
currentSelectedStep--;
handleUpdateStep();
}
});
function handleUpdateStep() {
iconsWrapper.forEach((item, index) => {
if (index < currentSelectedStep) {
item.classList.add("active");
} else {
item.classList.remove("active");
}
});
progress.style.width =
((currentSelectedStep - 1) / (iconsWrapper.length - 1)) * 100 + "%";
prevBtn.disabled = currentSelectedStep === 1;
nextBtn.disabled = currentSelectedStep === iconsWrapper.length;
// Add animation to the current step
iconsWrapper[currentSelectedStep - 1].style.transform = "scale(1.1)";
setTimeout(() => {
iconsWrapper[currentSelectedStep - 1].style.transform = "scale(1)";
}, 200);
}
// Keyboard navigation
document.addEventListener("keydown", (e) => {
if (e.key === "ArrowRight" && !nextBtn.disabled) {
nextBtn.click();
} else if (e.key === "ArrowLeft" && !prevBtn.disabled) {
prevBtn.click();
}
});
// Initialize progress bar
handleUpdateStep();
</script>
</body>
</html>