Learn how to create Progress-bar with simple Hmtl, Css and JavaScript.

Below are the codes:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="stylesheet" href="style.css" />
<title>Progress Bar</title>
</head>
<body>
<div class="container">
<div class="progress-container">
<div class="progress" id="progress"></div>
<div class="circle" id="active">1</div>
<div class="circle">2</div>
<div class="circle">3</div>
</div>
<button class="btn" id="prev" disabled>Prev</button>
<button class="btn" id="next">Next</button>
</div>
<script src="main.js"></script>
</body>
</html>
@import url("https://fonts.googleapis.com/css2?family=Akaya+Telivigala&display=swap");
* {
box-sizing: border-box;
}
:root {
--main-bg-color: aqua;
--line-border-fill: darkturquoise;
--line-border-empty: aliceblue;
}
body {
font-family: "Akaya Telivigala", cursive;
display: flex;
justify-content: center;
text-align: center;
overflow: hidden;
margin: 0;
}
.container {
align-items: center;
}
.progress-container {
display: flex;
justify-content: space-between;
align-items: center;
width: 400px;
max-width: 100%;
color: darkturquoise;
margin: 30px 0px;
position: relative;
}
.progress-container::before {
content: "";
position: absolute;
top: 50%;
left: 0;
transform: translateY(-50%);
height: 4px;
width: 100%;
z-index: -1;
transition: 0.4s ease;
background-color: var(--line-border-empty);
}
.progress {
background-color: var(--line-border-fill);
position: absolute;
top: 50%;
left: 0;
transform: translateY(-50%);
height: 5px;
width: 0%;
z-index: -1;
transition: 0.4s ease;
}
.circle {
color: #9fff;
border-radius: 50px;
height: 30px;
width: 30px;
display: flex;
justify-content: center;
align-items: center;
border: 3px solid var(--line-border-empty);
transition: 0.4s ease;
}
.circle.active {
border-color: var(--line-border-fill);
}
.btn {
border-radius: 50px;
background-color: aqua;
padding: 10px 30px;
border: 0;
color: white;
margin: 5px;
cursor: pointer;
}
.btn:active {
transform: scale(0.98);
}
.btn:disabled {
background-color: var(--line-border-empty);
cursor: not-allowed;
}
const progress = document.getElementById("progress");
const prev = document.getElementById("prev");
const next = document.getElementById("next");
const circles = document.querySelectorAll(".circle");
let currentActiveCircle = 1;
next.addEventListener("click", () => {
currentActiveCircle++;
if (currentActiveCircle > circles.length) {
currentActiveCircle = circles.length;
}
update();
});
prev.addEventListener("click", () => {
currentActiveCircle--;
if (currentActiveCircle < 1) {
currentActiveCircle = 1;
}
update();
});
function update() {
circles.forEach((circle, idz) => {
if (idz < currentActiveCircle) {
circle.classList.add("active");
} else {
circle.classList.remove("active");
}
});
const actives = document.querySelectorAll(".active");
progress.style.width =
((actives.lenght - 1) / (circles.length - 1)) * 100 + "%";
if (currentActiveCircle === 1) {
prev.disabled = true;
} else if (currentActiveCircle === circles.length) {
next.disabled = true;
} else {
prev.disabled = false;
next.disabled = false;
}
}
Tips:
Make sure to include the correct path of the respective files and folders.
You can use you own custom fonts and style.