Animation Choreography and Custom Easing
The difference between motion that feels designed and motion that feels accidental is usually not the animation itself. It is the timing relationships between animations. When six cards appear simultaneously, the page feels like it loaded. When they appear in sequence with a 60ms stagger, it feels like the interface is presenting them to you. Choreography is the craft of those timing relationships, and CSS gives you all the tools you need to build them without JavaScript.
This page covers the stagger calculation pattern, fill mode behavior in choreographed sequences, the skeleton-to-content crossfade pattern, and custom cubic-bezier() curves that give motion a physical character the named keyword values cannot express.
Stagger with animation-delay and :nth-child()
A stagger is a series of identical animations offset by a consistent delay increment. The simplest CSS approach targets each child with :nth-child() and adds delay manually:
.card:nth-child(1) { animation-delay: 0ms; }
.card:nth-child(2) { animation-delay: 60ms; }
.card:nth-child(3) { animation-delay: 120ms; }
.card:nth-child(4) { animation-delay: 180ms; }
This works but does not scale. Adding a fifth card means adding another rule. The scalable pattern uses a CSS custom property set inline on each element, either in the HTML or via JavaScript, and multiplies it in the animation delay:
.card {
animation: slide-up 400ms ease-out both;
animation-delay: calc(var(--index, 0) * 60ms);
}
<div class="card" style="--index: 0">...</div>
<div class="card" style="--index: 1">...</div>
<div class="card" style="--index: 2">...</div>
<div class="card" style="--index: 3">...</div>
If you are rendering the HTML server-side or templating it, the --index value is straightforward to inject. If the markup is static, a few lines of JavaScript can set it on page load:
document.querySelectorAll('.card').forEach((card, i) => {
card.style.setProperty('--index', i);
});
The stagger increment should be noticeably shorter than the animation duration. A 400ms animation with a 60ms stagger feels designed. The same animation with a 300ms stagger feels sluggish and makes users wait. A useful heuristic: stagger increment should be no more than 20 to 30 percent of the animation duration, and the total stagger across all items should complete within about one second.
animation-fill-mode in a Stagger Context
When items are staggered, later items sit in their pre-animation state during the delay period. Without animation-fill-mode: backwards, the element renders at its normal styles during the delay, then snaps to the from-state when the animation begins. The result is a visible jump: the card appears, then disappears, then fades in.
animation-fill-mode: backwards applies the first keyframe's values during the delay period, so the element is already invisible before its animation starts. both applies backwards behavior before the animation and forwards behavior after it, which is what staggered entrance animations almost always need:
@keyframes slide-up {
from {
opacity: 0;
transform: translateY(16px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.card {
animation: slide-up 400ms ease-out both;
animation-delay: calc(var(--index, 0) * 60ms);
/* "both" = invisible during delay, stays visible after animation ends */
}
Skeleton to Content Crossfade
A skeleton screen shows a placeholder layout while content loads. When the content arrives, the skeleton fades out and the real content fades in. Done with a stagger, the transition dissolves section by section rather than all at once, which reads as the page becoming ready progressively rather than snapping.
The pattern layers two elements in the same grid cell: a skeleton placeholder and the real content. Both sit at grid-area: 1 / 1 to stack them. When the content is ready, a class swap triggers the crossfade:
.skeleton-wrapper {
display: grid;
}
.skeleton,
.content {
grid-area: 1 / 1;
}
/* Skeleton fades out */
@keyframes fade-out {
to { opacity: 0; pointer-events: none; }
}
/* Content fades in with a slight upward movement */
@keyframes content-in {
from { opacity: 0; transform: translateY(8px); }
to { opacity: 1; transform: translateY(0); }
}
.is-loaded .skeleton {
animation: fade-out 300ms ease-in forwards;
animation-delay: calc(var(--index, 0) * 80ms);
}
.is-loaded .content {
animation: content-in 400ms ease-out both;
animation-delay: calc(var(--index, 0) * 80ms + 150ms);
/* The 150ms offset lets the skeleton begin fading before content appears */
}
<div class="skeleton-wrapper" style="--index: 0">
<div class="skeleton"></div>
<div class="content">Real content here</div>
</div>
<div class="skeleton-wrapper" style="--index: 1">
<div class="skeleton"></div>
<div class="content">More content here</div>
</div>
When content is ready, add is-loaded to a common parent and the staggered crossfade runs automatically across all wrappers.
Custom Easing with cubic-bezier()
Named easing keywords cover common cases but express a limited range of character. cubic-bezier() lets you define the exact shape of the acceleration curve. The four numbers are the x and y coordinates of two control points that bend the curve away from a straight diagonal line. Use cubic-bezier.com to drag and preview curves in real time before dropping them into CSS.
Three curves worth having in your toolkit, each with a distinct story:
The Considered Enter: cubic-bezier(0.16, 1, 0.3, 1)
Starts very fast and decelerates sharply to a precise stop. This is a more refined version of ease-out: the element arrives with purpose and settles cleanly without drifting. It works well for panels, modals, and cards entering the viewport. The fast start makes the motion feel responsive; the precise stop makes it feel controlled.
.panel {
animation: slide-in 400ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
The Spring: cubic-bezier(0.34, 1.56, 0.64, 1)
The y2 value above 1 causes the curve to overshoot its destination before settling back. This produces a spring-like bounce at the end of the motion that makes an element feel physical, as if it has slight elasticity. Use it on elements that grow or appear, like a modal scaling in or a badge popping into view. Avoid it on exit animations, where overshooting past the endpoint reads as confusion rather than energy.
.badge {
animation: pop-in 350ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
The Swift Exit: cubic-bezier(0.55, 0, 1, 0.45)
Starts slow and accelerates hard toward the end. This is a sharper version of ease-in, appropriate for exit animations where an element is being dismissed or removed. The slow start gives the user a moment to register the change; the accelerating exit clears the element quickly so the interface can move on.
.toast {
animation: slide-out 250ms cubic-bezier(0.55, 0, 1, 0.45) forwards;
}
Stagger and Easing Demo
The demo below replays a six-card entrance using the --index custom property pattern. Turn Stagger off to see all cards appear at once, then turn it back on to compare. Choose an easing curve from the menu and use Replay to run the sequence again. Slow motion stretches the timing so curve differences are easier to see.
Reduced Motion
Staggered entrance animations are a high-priority target for reduced-motion handling. Apply the standard guard inside a reduce block: remove the animation and leave every item in its finished visible state so the layout is complete without motion.
@media (prefers-reduced-motion: reduce) {
.card {
opacity: 1;
transform: none;
animation: none;
}
}
Build Your Demo
You have two options for where to build your portfolio demo:
-
Combine: Extend your motion prove assignment at
unit-6/motion/index.html. Replace the existing card entrance animation with a staggered version using the--indexcustom property pattern, and apply a customcubic-bezier()curve instead of a named keyword. -
Standalone: Create a new directory at
unit-6/choreography/withindex.htmlandchoreography.css. Build a page with a staggered list or card entrance and a skeleton-to-content crossfade.
Whichever path you choose, your demo must include:
-
A staggered entrance using the
--indexcustom property andcalc()delay pattern, applied to at least four elements. -
Correct use of
animation-fill-mode: bothso elements are invisible during their delay period and stay visible after the animation ends. -
At least one custom
cubic-bezier()curve (not a named keyword) applied to the animation, with a comment explaining what character it gives the motion. -
A
prefers-reduced-motionguard that removes the staggered animation and makes all elements immediately visible.
If you went the standalone route, add a link to your demo on your portfolio homepage and in your README.md.
Teaching Video Checklist
When you record your teaching video, make sure your teammates come away understanding these concepts:
-
The
--indexcustom property pattern and why it scales better than writing an:nth-child()rule for every item. Show what happens when you add a seventh card with no CSS changes needed. -
Why
animation-fill-mode: backwards(orboth) is required for staggered entrances to work correctly. Demonstrate the visual bug that appears without it: the snap from visible to invisible at animation start. -
At least two of the three custom
cubic-bezier()curves, shown side by side in slow motion so the difference in character is clearly visible. Use cubic-bezier.com in the video to show the curve shape as you explain it. -
Your portfolio demo: replay the stagger at full speed and then in slow motion. Walk through the CSS property by property: the keyframe, the
--indexcalc, the fill mode, and the easing curve.
Start the video by showing all six cards appearing simultaneously with no stagger, then adding the stagger. The before-and-after comparison makes the value of choreography immediately obvious without needing much explanation.
Resources
- MDN: animation-delay — Delay reference including negative delay values for pre-started animations
- MDN: animation-fill-mode — Full reference for none, forwards, backwards, and both
- MDN: easing-function — Complete reference for cubic-bezier(), named keywords, and steps()
- cubic-bezier.com — Visual editor for building and comparing custom easing curves with real-time preview