UI Components Easy
Mobile Stepper
A dot/step indicator for onboarding flows with animated transitions between steps. Includes skip and next/get-started buttons. No libraries.
Open in Lab
MCP
css vanilla-js
Targets: JS HTML
Code
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
margin: 0;
padding: 0;
overflow: hidden;
}
.onboarding {
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
position: relative;
}
/* Slides */
.slides-container {
flex: 1;
position: relative;
overflow: hidden;
}
.slide {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 40px 32px;
text-align: center;
opacity: 0;
transform: translateX(40px);
transition: opacity 0.4s ease, transform 0.4s ease;
pointer-events: none;
}
.slide.active {
opacity: 1;
transform: translateX(0);
pointer-events: all;
}
.slide.exit-left {
opacity: 0;
transform: translateX(-40px);
}
/* Illustrations */
.slide-illustration {
width: 180px;
height: 180px;
border-radius: 40px;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 40px;
}
.ill1 {
background: linear-gradient(135deg, #f59e0b, #ef4444);
}
.ill2 {
background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.ill3 {
background: linear-gradient(135deg, #10b981, #0ea5e9);
}
.ill-icon {
width: 80px;
height: 80px;
}
/* Text */
.slide-text h2 {
font-size: 26px;
font-weight: 800;
color: #111;
margin-bottom: 14px;
line-height: 1.2;
}
.slide-text p {
font-size: 16px;
color: #666;
line-height: 1.6;
max-width: 300px;
margin: 0 auto;
}
/* Footer */
.onboarding-footer {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px 24px 36px;
background: #fff;
border-top: 1px solid #f0f0f0;
gap: 16px;
}
.skip-btn {
border: none;
background: none;
font-size: 14px;
font-weight: 600;
color: #999;
cursor: pointer;
padding: 8px 4px;
min-width: 48px;
transition: color 0.2s;
}
.skip-btn:hover {
color: #555;
}
/* Dots */
.dots {
display: flex;
gap: 6px;
align-items: center;
}
.dot {
width: 8px;
height: 8px;
border-radius: 4px;
background: #d1d5db;
border: none;
padding: 0;
cursor: pointer;
transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
}
.dot.active {
width: 24px;
background: #6366f1;
}
/* Next / Get Started */
.next-btn {
padding: 10px 20px;
background: #6366f1;
color: #fff;
border: none;
border-radius: 12px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: transform 0.15s, background 0.2s;
min-width: 100px;
text-align: center;
}
.next-btn:active {
transform: scale(0.96);
}
.next-btn.finish {
background: #10b981;
}const slides = document.querySelectorAll(".slide");
const dots = document.querySelectorAll(".dot");
const nextBtn = document.getElementById("nextBtn");
const skipBtn = document.getElementById("skipBtn");
const total = slides.length;
let current = 0;
function goTo(index) {
if (index < 0 || index >= total) return;
// Exit current slide
slides[current].classList.remove("active");
slides[current].classList.add("exit-left");
setTimeout(() => slides[current].classList.remove("exit-left"), 400);
current = index;
// Enter new slide
slides[current].classList.add("active");
// Update dots
dots.forEach((dot, i) => dot.classList.toggle("active", i === current));
// Update next button
if (current === total - 1) {
nextBtn.textContent = "Get Started";
nextBtn.classList.add("finish");
skipBtn.style.visibility = "hidden";
} else {
nextBtn.textContent = "Next";
nextBtn.classList.remove("finish");
skipBtn.style.visibility = "visible";
}
}
nextBtn.addEventListener("click", () => {
if (current === total - 1) {
// "Get Started" action
nextBtn.textContent = "Done!";
setTimeout(() => {
nextBtn.textContent = "Get Started";
goTo(0);
skipBtn.style.visibility = "visible";
}, 1500);
} else {
goTo(current + 1);
}
});
skipBtn.addEventListener("click", () => goTo(total - 1));
dots.forEach((dot) => {
dot.addEventListener("click", () => goTo(Number(dot.dataset.step)));
});<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Mobile Stepper</title>
</head>
<body>
<div class="onboarding" id="onboarding">
<!-- Slides -->
<div class="slides-container" id="slidesContainer">
<div class="slide active" data-step="0">
<div class="slide-illustration ill1">
<svg class="ill-icon" viewBox="0 0 80 80" fill="none">
<circle cx="40" cy="40" r="36" fill="rgba(255,255,255,0.15)"/>
<path d="M20 52L32 36l10 12 8-10 10 14H20z" fill="rgba(255,255,255,0.6)"/>
<circle cx="52" cy="28" r="6" fill="rgba(255,255,255,0.8)"/>
</svg>
</div>
<div class="slide-text">
<h2>Beautiful on every screen</h2>
<p>Designed for mobile-first experiences that feel natural and fluid on any device.</p>
</div>
</div>
<div class="slide" data-step="1">
<div class="slide-illustration ill2">
<svg class="ill-icon" viewBox="0 0 80 80" fill="none">
<circle cx="40" cy="40" r="36" fill="rgba(255,255,255,0.15)"/>
<rect x="20" y="24" width="40" height="32" rx="4" fill="rgba(255,255,255,0.3)"/>
<rect x="26" y="30" width="16" height="3" rx="1.5" fill="rgba(255,255,255,0.8)"/>
<rect x="26" y="36" width="28" height="3" rx="1.5" fill="rgba(255,255,255,0.6)"/>
<rect x="26" y="42" width="20" height="3" rx="1.5" fill="rgba(255,255,255,0.5)"/>
</svg>
</div>
<div class="slide-text">
<h2>Instant, no-friction access</h2>
<p>One tap to get to what matters. No loading screens, no unnecessary steps.</p>
</div>
</div>
<div class="slide" data-step="2">
<div class="slide-illustration ill3">
<svg class="ill-icon" viewBox="0 0 80 80" fill="none">
<circle cx="40" cy="40" r="36" fill="rgba(255,255,255,0.15)"/>
<path d="M28 40l8 8 16-16" stroke="rgba(255,255,255,0.9)" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</div>
<div class="slide-text">
<h2>You're all set</h2>
<p>Everything is configured and ready. Tap Get Started to begin your journey.</p>
</div>
</div>
</div>
<!-- Bottom bar -->
<div class="onboarding-footer">
<button class="skip-btn" id="skipBtn">Skip</button>
<div class="dots" id="dots" aria-label="Step indicator" role="tablist">
<button class="dot active" data-step="0" role="tab" aria-label="Step 1"></button>
<button class="dot" data-step="1" role="tab" aria-label="Step 2"></button>
<button class="dot" data-step="2" role="tab" aria-label="Step 3"></button>
</div>
<button class="next-btn" id="nextBtn">Next</button>
</div>
</div>
<script src="script.js"></script>
</body>
</html>Mobile Stepper
A fullscreen onboarding carousel with dot step indicators. Slides transition with a smooth horizontal animation. The dot indicator stretches the active dot into a pill shape.
How it works
- Slides are positioned absolutely and transition via
opacity+translateX - Active dot expands to a pill using a CSS
widthtransition - “Next” advances the step; the last step shows “Get Started”
- “Skip” jumps directly to the final step
Customization
- Swap the illustration area with real images or Lottie animations
- Add
swipe-tabs-style touch swipe support for gesture navigation - Adjust
--accentto retheme the entire component
When to use it
- App onboarding flows (2–5 steps)
- Feature introduction overlays
- Tutorial wizards