AnimationsIntermediateApril 8, 2026
Stairs Wipe
5 full-height columns cascade down in a staircase sequence wiping the screen black, then reveal the new page. Each column has a custom delay of 0.05 * (5 - index) for the staircase order.
View Full Demo →Preview
Source
index.jsx
"use client";
import { useState } from "react";
import { AnimatePresence, motion } from "framer-motion";
import styles from "./styles.module.css";
const PAGES = [
{ key: "home", label: "Home", bg: "#f5f5f5", color: "#1a1a1a" },
{ key: "about", label: "About", bg: "#0d0d0d", color: "#ffffff" },
{ key: "work", label: "Work", bg: "#1a1f2e", color: "#ffffff" },
];
const NUM_COLUMNS = 5;
function getStepVariants(custom) {
return {
initial: { top: "-100%" },
enter: { top: "-100%", transition: { duration: 0 } },
exit: {
top: 0,
transition: {
duration: 0.4,
ease: [0.76, 0, 0.24, 1],
delay: 0.05 * custom,
},
},
};
}
export default function StairsWipe() {
const [pageIndex, setPageIndex] = useState(0);
const [isAnimating, setIsAnimating] = useState(false);
const page = PAGES[pageIndex];
function navigate(nextIndex) {
if (isAnimating || nextIndex === pageIndex) return;
setIsAnimating(true);
setPageIndex(nextIndex);
setTimeout(() => setIsAnimating(false), 900);
}
return (
<div className={styles.demo}>
<div className={styles.viewport}>
{/* Staircase columns */}
<AnimatePresence>
{Array.from({ length: NUM_COLUMNS }).map((_, i) => (
<motion.div
key={`col-${pageIndex}-${i}`}
className={styles.column}
style={{ left: `${(i / NUM_COLUMNS) * 100}%`, width: `${100 / NUM_COLUMNS}%` }}
custom={NUM_COLUMNS - i}
variants={getStepVariants(NUM_COLUMNS - i)}
initial="initial"
animate="enter"
exit="exit"
/>
))}
</AnimatePresence>
{/* Page content */}
<AnimatePresence mode="wait">
<motion.div
key={`page-${pageIndex}`}
className={styles.page}
style={{ background: page.bg, color: page.color }}
initial={{ opacity: 0 }}
animate={{ opacity: 1, transition: { delay: 0.4, duration: 0.3 } }}
exit={{ opacity: 0, transition: { duration: 0.1 } }}
>
<h2 className={styles.pageTitle}>{page.label}</h2>
</motion.div>
</AnimatePresence>
</div>
<div className={styles.nav}>
{PAGES.map((p, i) => (
<button
key={p.key}
className={`${styles.navBtn} ${i === pageIndex ? styles.active : ""}`}
onClick={() => navigate(i)}
>
{p.label}
</button>
))}
</div>
</div>
);
}
styles.module.css
.demo {
display: flex;
flex-direction: column;
}
.viewport {
position: relative;
height: 320px;
overflow: hidden;
}
.column {
position: absolute;
top: -100%;
height: 100%;
background: #1a1a1a;
z-index: 10;
}
.page {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
}
.pageTitle {
font-size: 2.5rem;
font-weight: 700;
letter-spacing: -0.03em;
}
.nav {
display: flex;
gap: 1px;
background: #e5e5e5;
border-top: 1px solid #e5e5e5;
}
.navBtn {
flex: 1;
padding: 0.875rem;
font-size: 0.875rem;
font-weight: 500;
font-family: inherit;
background: #ffffff;
border: none;
cursor: pointer;
color: #6b6b6b;
transition: background 150ms ease, color 150ms ease;
}
.navBtn:hover {
background: #f5f5f5;
color: #1a1a1a;
}
.navBtn.active {
background: #1a1a1a;
color: #ffffff;
}
Dependencies
framer-motion