Give a List One Motion Budget, Not Forty Delays
Use `sibling-index()` to stagger the first few notifications, then cap the delay so a batch of forty settles just as quickly as a batch of seven. The text stays readable throughout.
Set a deadline for the batch
A file import finishes and the results panel fills with notifications: “Invoice saved,” “Receipt saved,” “Address missing.” A slight movement can help someone notice that the panel has updated. But if the address warning is the fortieth result, it shouldn't still be moving a second after the first result has settled. The user may already be trying to read it.
Give the batch two timing rules: start neighboring entries 30ms apart, but start every entry within 180ms. The first few results get a discernible sequence. The rest settle together. With a 120ms animation, that gives results inserted together a total scheduled motion budget of 300ms, whether there are seven entries or forty.
Make the resting state the default
Use an unordered list with the class .results and give each notification list item the class .result. For this example, render a fresh list when the import finishes, so the items join the page as one batch. No item needs an inline delay or a numbered class.
.results {
display: grid;
gap: 0.75rem;
margin: 0;
padding: 0;
list-style: none;
}
.results > .result {
padding: 0.75rem 1rem;
border-inline-start: 0.25rem solid steelblue;
background: #f1f5f9;
color: #172033;
}
@keyframes result-settle {
from { transform: translateY(3px); }
to { transform: translateY(0); }
}
Stop here and you have a usable results panel. Defining keyframes doesn't apply them. Each message occupies its place in the grid, with ordinary, fully visible text. Even in the enhanced version there's no fade: the difference between “waiting” and “finished” is three pixels of offset, not whether someone can read the warning.
Derive the delay from the item's place
Put the whole animation declaration behind two checks. The media query asks whether the user has expressed no preference for reduced motion. The feature query checks whether the browser accepts the actual delay declaration, including the function and the arithmetic, rather than checking for CSS math in general.
@media (prefers-reduced-motion: no-preference) {
@supports (animation-delay: min(180ms, calc((sibling-index() - 1) * 30ms))) {
.results > .result {
animation: result-settle 120ms ease-out backwards;
animation-delay: min(180ms, calc((sibling-index() - 1) * 30ms));
}
}
}
Read the calculation from the inside out. sibling-index() gives the element's one-based position among its element siblings. Subtract one to get the number of steps to wait; multiply by 30ms to turn that count into a time. Finally, min() takes the shorter of that time and 180ms.
- Entry 1: zero steps, so it starts at 0ms.
- Entry 2: one step, so it starts at 30ms.
- Entry 7: six steps, so it starts at 180ms.
- Entry 40: thirty-nine steps would mean 1170ms, but it starts at 180ms too.
The backwards fill mode holds a delayed entry at the starting offset until its turn. Without it, that entry would sit at rest, jump down three pixels when its delay expired, then glide back. Keep animation-delay after the animation shorthand: moving the shorthand below it would reset the delay.
Find out what counts as a sibling
Try a short list of three results. Their scheduled starts are 0ms, 30ms and 60ms. Now insert a plain list item labeled “Attachments” between the first and second results. Leave .result off that label. It won't animate, but it will occupy position two. The second result now starts at 60ms and the third at 90ms.
The selector decides which elements animate; it doesn't filter the index calculation. Whitespace and comments don't take a slot, but other element children do. If “Attachments” names a distinct batch, put that label before a separate results list. The first attachment then has index one under its own parent, and its sequence starts without a compensating delay in the CSS.
Compare a wrapped layout and a quiet one
To see what happens when the panel gets wider, let the same grid form as many columns as fit:
.results {
grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}
With three columns, the fourth result begins a new row. It still starts at 90ms in a list containing only results; it doesn't restart at zero because it reached the left edge. Narrow the panel to one column and that fourth item keeps the same timing. The sequence describes sibling order, not distance across the screen.
Finally, compare the panel with reduced motion enabled. Neither the delay nor the transform animation should apply: the results arrive already at rest. A browser that doesn't accept the delay expression gets that same static presentation. calc() and min() are established CSS tools; sibling-index() is the newer dependency, and its support needs verification in your target browsers. A feature query is a fallback mechanism, not a substitute for that check. The useful acceptance criterion in either rendering is simple: someone can read the last warning as soon as the batch arrives.