Step Navigation (Indicator)
Clearly guide users through multi-stage UIs.
π Live Demo (Arrow Type)
π§© Advanced Demo (Step-linked Form)
Contact Form
π Related Code
HTML for Step Navigation (Arrows)
<div class="step-nav">
<div class="step completed">β Input</div>
<div class="step current">β‘ Confirm</div>
<div class="step">β’ Complete</div>
</div>
HTML for Step Indicator (Dots)
<div class="step-indicator-dots">
<div class="step-circle completed">1</div>
<div class="step-circle active">2</div>
<div class="step-circle">3</div>
</div>
π Step Navigation with Arrow Indicator
This demo explicitly indicates the user's current step with "ββββββ" and text. It's useful for multi-stage UIs like forms from input to submission.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.step-nav {
display: flex;
justify-content: space-around;
font-weight: bold;
margin: 2rem 0;
position: relative;
}
.step {
color: gray;
position: relative;
}
.step.current {
color: #007bff;
}
.step.current::after {
content: " ββββββ\A You are here";
white-space: pre;
position: absolute;
top: 2em;
left: 50%;
transform: translateX(-50%);
font-size: 0.8rem;
color: #007bff;
pointer-events: none;
}
.step.completed {
color: green;
}
.step.completed::before {
content: "β ";
color: green;
}
</style>
</head>
<body>
<div class="step-nav">
<div class="step current">β Input</div>
<div class="step">β‘ Confirm</div>
<div class="step">β’ Complete</div>
</div>
<br><br>
<div style="text-align: center;">
<button onclick="nextStep()">Next βΆ</button>
</div>
<script>
function nextStep() {
const steps = document.querySelectorAll(".step-nav .step");
const current = document.querySelector(".step.current");
if (!current) return;
current.classList.remove("current");
current.classList.add("completed");
const next = current.nextElementSibling;
if (next) {
next.classList.add("current");
}
}
</script>
</body>
</html>
π Use Cases & Benefits of this Template
- Progress is obvious at a glance in step-based UIs.
- Users can intuitively understand where they are.
- Ideal for forms, purchase flows, and surveys.
- Improves UX with arrows and color changes.
- Allows for step control with JavaScript (extensible).
π§© Advanced Step UI: Linking with State Management and Block Control
This template helps prevent users from getting lost and reduces drop-off rates in forms and purchase flows by visually clarifying the progress.
A more advanced use case is to toggle content blocks for each step. By combining with JavaScript's `display: none`, you can create a UX where only the input form for the current step is displayed, and the content switches when moving to the next step.
For example:
- Input Step: Display the form fields
- Confirm Step: Display the confirmation screen
- Complete Step: Display the completion message
By synchronizing the step with the content, you can develop a more dynamic and intuitive UI.
Furthermore, when considering integration with frameworks like Vue or React, it becomes easier to control validation and back-navigation for each step through state management, making it applicable for building practical SPAs (Single Page Applications).
You can also create a contact form like the one below
Contact Form
Basic Information
<div class="unique-step-form-container" style="font-family: Arial, sans-serif; max-width: 600px; margin: 20px auto; padding: 20px; border: 1px solid #eee; border-radius: 8px; background: #fafafa;">
<h2 style="text-align: center; color: #333; margin-bottom: 25px;">Contact Form</h2>
<div class="unique-step-indicator" style="display: flex; justify-content: center; margin-bottom: 25px;">
<div class="unique-step-circle active" data-unique-step="1" style="width: 30px; height: 30px; border-radius: 50%; background-color: #4CAF50; color: white; display: flex; align-items: center; justify-content: center; margin: 0 10px;">1</div>
<div class="unique-step-circle" data-unique-step="2" style="width: 30px; height: 30px; border-radius: 50%; background-color: #ddd; display: flex; align-items: center; justify-content: center; margin: 0 10px;">2</div>
<div class="unique-step-circle" data-unique-step="3" style="width: 30px; height: 30px; border-radius: 50%; background-color: #ddd; display: flex; align-items: center; justify-content: center; margin: 0 10px;">3</div>
</div>
<div class="unique-step-container" style="position: relative; min-height: 300px;">
<!-- Step 1: Basic Information -->
<div class="unique-step active" id="unique-step1" style="display: block; padding: 20px; border: 1px solid #ddd; border-radius: 5px; background-color: #f9f9f9; animation: uniqueFadeIn 0.5s;">
<h3 style="margin-top: 0; color: #444;">Basic Information</h3>
<div class="unique-form-group" style="margin-bottom: 15px;">
<label for="unique-name" style="display: block; margin-bottom: 5px; font-weight: bold;">Name</label>
<input type="text" id="unique-name" required style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div class="unique-form-group" style="margin-bottom: 15px;">
<label for="unique-email" style="display: block; margin-bottom: 5px; font-weight: bold;">Email Address</label>
<input type="email" id="unique-email" required style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div class="unique-btn-group" style="margin-top: 20px; display: flex; justify-content: space-between;">
<button disabled class="unique-btn-prev" style="padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; background-color: #f0f0f0; color: #999;">Previous</button>
<button class="unique-btn-next" onclick="uniqueNextStep(1)" style="padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; background-color: #4CAF50; color: white;">Next</button>
</div>
</div>
<!-- Step 2: Detailed Information -->
<div class="unique-step" id="unique-step2" style="display: none; padding: 20px; border: 1px solid #ddd; border-radius: 5px; background-color: #f9f9f9;">
<h3 style="margin-top: 0; color: #444;">Detailed Information</h3>
<div class="unique-form-group" style="margin-bottom: 15px;">
<label for="unique-subject" style="display: block; margin-bottom: 5px; font-weight: bold;">Subject</label>
<input type="text" id="unique-subject" required style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
</div>
<div class="unique-form-group" style="margin-bottom: 15px;">
<label for="unique-message" style="display: block; margin-bottom: 5px; font-weight: bold;">Message</label>
<textarea id="unique-message" rows="5" required style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;"></textarea>
</div>
<div class="unique-btn-group" style="margin-top: 20px; display: flex; justify-content: space-between;">
<button class="unique-btn-prev" onclick="uniquePrevStep(2)" style="padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; background-color: #f0f0f0;">Previous</button>
<button class="unique-btn-next" onclick="uniqueNextStep(2)" style="padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; background-color: #4CAF50; color: white;">Next</button>
</div>
</div>
<!-- Step 3: Confirmation -->
<div class="unique-step" id="unique-step3" style="display: none; padding: 20px; border: 1px solid #ddd; border-radius: 5px; background-color: #f9f9f9;">
<h3 style="margin-top: 0; color: #444;">Confirmation</h3>
<div id="unique-confirmation-content" style="margin-bottom: 20px;">
<!-- Confirmation content is dynamically displayed here -->
</div>
<div class="unique-btn-group" style="margin-top: 20px; display: flex; justify-content: space-between;">
<button class="unique-btn-prev" onclick="uniquePrevStep(3)" style="padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; background-color: #f0f0f0;">Previous</button>
<button class="unique-btn-next" onclick="uniqueSubmitForm()" style="padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; background-color: #4CAF50; color: white;">Submit</button>
</div>
</div>
<!-- Step 4: Completion -->
<div class="unique-step" id="unique-step4" style="display: none; padding: 20px; border: 1px solid #ddd; border-radius: 5px; background-color: #f9f9f9; text-align: center;">
<h3 style="margin-top: 0; color: #444;">Submission Complete</h3>
<p style="color: #4CAF50; font-weight: bold;">Thank you for your inquiry</p>
<p>We will reply within 3 business days.</p>
</div>
</div>
</div>
<script>
// Scope definition
(function() {
let uniqueCurrentStep = 1;
const uniqueTotalSteps = 4;
window.uniqueNextStep = function(step) {
if (step === 1) {
const name = document.getElementById('unique-name').value;
const email = document.getElementById('unique-email').value;
if (!name || !email) {
alert('Please fill in required fields');
return;
}
} else if (step === 2) {
const subject = document.getElementById('unique-subject').value;
const message = document.getElementById('unique-message').value;
if (!subject || !message) {
alert('Please fill in required fields');
return;
}
}
if (step === 2) {
uniqueUpdateConfirmation();
}
document.getElementById(`unique-step${step}`).style.display = 'none';
document.getElementById(`unique-step${step+1}`).style.display = 'block';
document.getElementById(`unique-step${step+1}`).style.animation = 'uniqueFadeIn 0.5s';
document.querySelector(`.unique-step-circle[data-unique-step="${step}"]`).style.backgroundColor = '#ddd';
document.querySelector(`.unique-step-circle[data-unique-step="${step}"]`).style.color = '#333';
document.querySelector(`.unique-step-circle[data-unique-step="${step+1}"]`).style.backgroundColor = '#4CAF50';
document.querySelector(`.unique-step-circle[data-unique-step="${step+1}"]`).style.color = 'white';
uniqueCurrentStep = step + 1;
};
window.uniquePrevStep = function(step) {
document.getElementById(`unique-step${step}`).style.display = 'none';
document.getElementById(`unique-step${step-1}`).style.display = 'block';
document.getElementById(`unique-step${step-1}`).style.animation = 'uniqueFadeIn 0.5s';
document.querySelector(`.unique-step-circle[data-unique-step="${step}"]`).style.backgroundColor = '#ddd';
document.querySelector(`.unique-step-circle[data-unique-step="${step}"]`).style.color = '#333';
document.querySelector(`.unique-step-circle[data-unique-step="${step-1}"]`).style.backgroundColor = '#4CAF50';
document.querySelector(`.unique-step-circle[data-unique-step="${step-1}"]`).style.color = 'white';
uniqueCurrentStep = step - 1;
};
function uniqueUpdateConfirmation() {
const name = document.getElementById('unique-name').value;
const email = document.getElementById('unique-email').value;
const subject = document.getElementById('unique-subject').value;
const message = document.getElementById('unique-message').value;
const content = `
<div style="margin-bottom: 15px;">
<h4 style="margin-bottom: 10px; color: #555;">Basic Information</h4>
<p style="margin: 5px 0;"><strong>Name:</strong> ${name}</p>
<p style="margin: 5px 0;"><strong>Email Address:</strong> ${email}</p>
</div>
<div style="margin-bottom: 15px;">
<h4 style="margin-bottom: 10px; color: #555;">Detailed Information</h4>
<p style="margin: 5px 0;"><strong>Subject:</strong> ${subject}</p>
<p style="margin: 5px 0 10px;"><strong>Message:</strong></p>
<div style="background:#fff; padding:10px; border:1px solid #eee; border-radius:4px; margin-bottom: 15px;">${message.replace(/\n/g, '<br>')}</div>
</div>
<p style="margin-top:20px; color:#666; font-size: 0.9em;">Please review the information above and click the submit button.</p>
`;
document.getElementById('unique-confirmation-content').innerHTML = content;
}
window.uniqueSubmitForm = function() {
document.getElementById('unique-step3').style.display = 'none';
document.getElementById('unique-step4').style.display = 'block';
document.getElementById('unique-step4').style.animation = 'uniqueFadeIn 0.5s';
document.querySelector(`.unique-step-circle[data-unique-step="3"]`).style.backgroundColor = '#ddd';
document.querySelector(`.unique-step-circle[data-unique-step="4"]`).style.backgroundColor = '#4CAF50';
document.querySelector(`.unique-step-circle[data-unique-step="4"]`).style.color = 'white';
uniqueCurrentStep = 4;
};
const style = document.createElement('style');
style.textContent = '@keyframes uniqueFadeIn {from { opacity: 0; } to { opacity: 1; }}';
document.head.appendChild(style);
})();
</script>
</section>