Stop Passing Index Props: Staggered Animations with sibling-index()
October 6, 2026 | 8 min read | CSS
By Syed · Frontend Engineer & Creator of UITweak
You want list items to fade in one after another. So you drill an index prop through four components, compute transitionDelay: index * 80 + "ms" inline, and hope nobody reorders the list. Every React developer has written this code. CSS just made it obsolete: sibling-index() gives every element its own position among its siblings, directly in the stylesheet. No props, no inline styles, no JavaScript at all.
30-second version: sibling-index() returns 1 for the first sibling, 2 for the second, and so on. sibling-count() returns the total. Both are Baseline across modern browsers as of 2026, so this is shippable today with a one-line fallback.
Recipe 1: The Basic Stagger
The whole trick in three lines. Every list item delays itself based on its own position:
.stagger > li {
animation: rise 0.5s ease both;
animation-delay: calc(90ms * sibling-index());
}
@keyframes rise {
from { opacity: 0; translate: 0 12px; }
to { opacity: 1; translate: 0 0; }
}Add or remove items and the stagger recalculates itself. Reorder the list and the delays follow. There is no state to keep in sync because there is no state. If keyframes are new to you, our CSS animation guide covers the fundamentals; for choreographing enter and exit, @starting-style is the companion technique.
Recipe 2: Stagger From the Center (or the End)
Combine both functions to stagger outward from the middle, or reverse the direction entirely:
/* latest item animates first */
.stagger-reverse > li {
animation: rise 0.5s ease both;
animation-delay: calc(90ms * (sibling-count() - sibling-index()));
}
/* middle-out: distance from center drives the delay */
.stagger-center > li {
animation: rise 0.5s ease both;
animation-delay: calc(90ms *
abs(sibling-count() / 2 - sibling-index()));
}The middle-out version needs no knowledge of the list length. It works for 5 items and 500.
Recipe 3: The Avatar Stack z-index Trick
Overlapping avatar stacks need later avatars painted under earlier ones, which classically means hand-written z-index values or more prop drilling. One line does it:
.avatars > img {
margin-left: -12px;
z-index: calc(sibling-count() - sibling-index());
position: relative;
}The first avatar gets the highest z-index, each next one sits one level lower. Add a tenth avatar and the stack stays correct with zero changes.
Recipe 4: Color Cycling Without nth-child Walls
Repeating patterns used to mean writing :nth-child(3n+1), :nth-child(3n+2), :nth-child(3n+3) until your eyes glazed. Feed the index into a hue instead:
.cycle > li {
background: oklch(0.7 0.15 calc(40 * sibling-index()));
border-left: 4px solid
oklch(0.55 0.2 calc(40 * sibling-index()));
}Each item gets a distinct hue step with no repetition limit and no selector list to maintain.
The Fallback (One @supports Block)
For the last browsers without support, gate the fancy version and keep a sane default. Everyone still sees the content; only the stagger is skipped:
.stagger > li {
animation: rise 0.5s ease both; /* everyone animates */
}
@supports (animation-delay: calc(1ms * sibling-index())) {
.stagger > li {
animation-delay: calc(90ms * sibling-index()); /* stagger where supported */
}
}This is the correct degradation: the animation is an enhancement, the content is the baseline. Never hide content behind a feature query.
Try it now: design the stagger motion itself in our free CSS Animation Generator: pick your easing, duration, and distance, preview it live, then multiply the delay with calc(... * sibling-index()) from Recipe 1. You get a hand-tuned stagger with zero prop drilling.
Quick Recap
sibling-index()is the 1-based position among siblings;sibling-count()is the total.animation-delay: calc(90ms * sibling-index())staggers any list with no JavaScript.- Combine with
sibling-count()for reverse, center-out, and z-index stacks. - Gate behind
@supports; content must never depend on the enhancement.
Constant Total Duration, Any List Length
A fixed per-item delay means a fifty-item list staggers for seconds. Divide by the count instead: animation-delay: calc(600ms * sibling-index() / sibling-count()) spreads the whole stagger across a fixed budget no matter how many items render. Adding items makes each step smaller; the total never grows. I use this for notification stacks and search results, where the list length is data and the animation budget is not. Pick the budget first (I stay under a second), then let the math distribute it.
.results > li {
animation: rise 0.4s ease both;
/* whole stagger always spans 600ms, whatever the count */
animation-delay: calc(600ms * sibling-index() / sibling-count());
}Exit Staggers: Closing in Reverse
Entrance staggers run first-to-last. For a menu closing, last-to-first feels right: the bottom item leaves first, like a collapsing stack. Flip the math with sibling-count() minus sibling-index(), and scope it under a .closing class so entrances and exits use different delays on the same list. The same trick works for hover cascades that should ripple back up when the pointer leaves. Entrance and exit are two different choreographies; write them as two rules and stop trying to make one delay serve both.
.menu > li {
transition: opacity 0.25s ease, translate 0.25s ease;
transition-delay: calc(40ms * sibling-index());
}
.menu.closing > li {
opacity: 0;
translate: 0 8px;
transition-delay: calc(40ms * (sibling-count() - sibling-index()));
}Nested Lists Shift the Count
sibling-index() counts every element sibling, not just the ones your selector matches. A ul with a header div, or li elements that contain nested uls, shifts every number after the intruder. The symptom is a stagger that starts late or skips a beat: item one waits as if it were item three. Scope the selector with the child combinator (.menu > li) and keep stagger lists to uniform children. When the markup cannot change, there is no CSS workaround for the shift. That list keeps its index props, and that is fine. Not every list wants this function.
Respect Reduced Motion: Delays Count Too
Reduced-motion handling usually kills the movement, but the delays themselves are motion too. Ninety milliseconds per item across thirty items is 2.7 seconds of choreography for someone who asked for less motion. Zero the delay inside the reduced-motion query, not just the animation. And keep any stagger you keep under about a second of total time. Beyond that it stops feeling like polish and starts feeling like waiting. Accessibility reviewers flag long staggers, and they are right to.
@media (prefers-reduced-motion: reduce) {
.stagger > li {
animation: none;
}
}Transition-Based Staggers for Hover Cascades
Animations run once; transitions re-run every time state changes, which makes them the right tool for hover cascades. A nav menu where each item lifts slightly, rippling down the list as the pointer travels: transition-delay: calc(60ms * sibling-index()) on the items, triggered by the parent's hover state. The delays apply on the way in and on the way out, since transitions re-evaluate from current values in both directions. Keep the per-item delay small here. Hover cascades feel laggy fast, and 60ms per item is already noticeable across ten items.
.nav > a {
transition: translate 0.2s ease;
transition-delay: calc(60ms * sibling-index());
}
.nav:hover > a {
translate: 0 -2px;
}Frequently Asked Questions
Does sibling-index() count all siblings or only matching ones?
All element siblings, regardless of selector. If your li elements share a parent with a header div, the header counts as sibling 1. Keep stagger lists to uniform children, or scope the selector so stray siblings do not shift your math.
Can I use it in transitions, not just animations?
Yes: transition-delay: calc(90ms * sibling-index()) works the same way. It is handy for hover cascades, where each item's hover transition ripples down the list.
What about performance with hundreds of items?
The index is computed by the style engine, not JavaScript, so it is cheap. The real cost is animating hundreds of opacity/translate layers at once, which is the same cost your prop-drilled version had. Cap the visible stagger or virtualize long lists either way.
How do I stagger animations in CSS without JavaScript?
Use sibling-index() inside calc() for your animation-delay: animation-delay: calc(80ms * sibling-index()). Each sibling automatically gets a delay proportional to its position, no JavaScript, no nth-child walls, no index props drilled through components.
What is the difference between sibling-index() and nth-child?
nth-child selects elements by position; you still hand-write a rule per item. sibling-index() returns the position as a number you can compute with, so one declaration staggers the whole list. Think of nth-child as matching and sibling-index() as measuring.
Which browsers support sibling-index()?
Chromium and Safari ship it; Firefox support was still rolling out at the time of writing. Always include the @supports fallback from the section above so unsupported browsers get a clean simultaneous entrance instead of broken delays.
How do I add a fallback for browsers without sibling-index()?
Wrap the sibling-index() styles in @supports (animation-delay: calc(1ms * sibling-index())) and put a plain no-delay animation outside it. Browsers that understand the function get the stagger; the rest get every item animating together, which is always an acceptable default.