https://prismic.io/blog/tailwind-component-library
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form with DaisyUI Steps</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdn.jsdelivr.net/npm/daisyui@2.51.5/dist/full.css" rel="stylesheet">
</head>
<body class="bg-gray-100">
<div class="container mx-auto p-8">
<h1 class="text-2xl font-bold mb-4">Multi-Step Form Example</h1>
<!-- Steps -->
<ul class="steps mb-8">
<li class="step step-primary">Step 1</li>
<li class="step">Step 2</li>
<li class="step">Step 3</li>
</ul>
<!-- Form -->
<div class="bg-white shadow-md rounded-lg p-6">
<form id="multiStepForm">
<!-- Step 1 -->
<div id="step1" class="step-content">
<h2 class="text-xl font-bold mb-4">Step 1: Personal Information</h2>
<div class="mb-4">
<label class="block text-sm font-medium mb-2" for="name">Name</label>
<input type="text" id="name" class="input input-bordered w-full" placeholder="Enter your name" required>
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-2" for="email">Email</label>
<input type="email" id="email" class="input input-bordered w-full" placeholder="Enter your email" required>
</div>
<button type="button" class="btn btn-primary mt-4" onclick="nextStep()">Next</button>
</div>
<!-- Step 2 -->
<div id="step2" class="step-content hidden">
<h2 class="text-xl font-bold mb-4">Step 2: Address</h2>
<div class="mb-4">
<label class="block text-sm font-medium mb-2" for="address">Address</label>
<input type="text" id="address" class="input input-bordered w-full" placeholder="Enter your address" required>
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-2" for="city">City</label>
<input type="text" id="city" class="input input-bordered w-full" placeholder="Enter your city" required>
</div>
<button type="button" class="btn btn-secondary" onclick="prevStep()">Previous</button>
<button type="button" class="btn btn-primary mt-4" onclick="nextStep()">Next</button>
</div>
<!-- Step 3 -->
<div id="step3" class="step-content hidden">
<h2 class="text-xl font-bold mb-4">Step 3: Confirm</h2>
<p class="mb-4">Please confirm your information before submitting the form.</p>
<button type="button" class="btn btn-secondary" onclick="prevStep()">Previous</button>
<button type="submit" class="btn btn-success mt-4">Submit</button>
</div>
</form>
</div>
</div>
<script>
let currentStep = 1;
function showStep(step) {
document.querySelectorAll('.step-content').forEach((content, index) => {
content.classList.toggle('hidden', index + 1 !== step);
});
document.querySelectorAll('.step').forEach((stepItem, index) => {
if (index < step) {
stepItem.classList.add('step-primary');
} else {
stepItem.classList.remove('step-primary');
}
});
}
function nextStep() {
if (currentStep < 3) {
currentStep++;
showStep(currentStep);
}
}
function prevStep() {
if (currentStep > 1) {
currentStep--;
showStep(currentStep);
}
}
// Initialize first step
showStep(currentStep);
</script>
</body>
</html>