A three by three grid pops in along the diagonal, each tile overshooting and settling. Every tile's --i is its row plus its column, so tiles on the same diagonal land together.
Also known as: staggered grid animation css, grid items pop in, diagonal stagger animation.
<div class="kfa-staggered-grid-pop"><span style="--i: 0"></span><span style="--i: 1"></span><span style="--i: 2"></span><span style="--i: 1"></span><span style="--i: 2"></span><span style="--i: 3"></span><span style="--i: 2"></span><span style="--i: 3"></span><span style="--i: 4"></span></div>
.kfa-staggered-grid-pop {
--c: var(--kfa-color, #3b82f6);
font-size: var(--kfa-size, 16px);
display: grid;
grid-template-columns: repeat(3, 1.9em);
gap: 0.4em;
}
.kfa-staggered-grid-pop > span {
height: 1.9em;
border-radius: 0.45em;
background: var(--c);
box-shadow: 0 0.3em 0.7em -0.35em color-mix(in srgb, var(--c) 80%, transparent);
animation: kfa-staggered-grid-pop-in 0.55s calc(var(--i) * 75ms) both;
}
.kfa-staggered-grid-pop > span:nth-child(even) {
background: color-mix(in srgb, var(--c) 55%, transparent);
}
@keyframes kfa-staggered-grid-pop-in {
0% { opacity: 0; transform: scale(0); animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1); }
55% { opacity: 1; transform: scale(1.15); animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1); }
80% { transform: scale(0.96); }
100% { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
.kfa-staggered-grid-pop, .kfa-staggered-grid-pop *, .kfa-staggered-grid-pop::before, .kfa-staggered-grid-pop::after, .kfa-staggered-grid-pop *::before, .kfa-staggered-grid-pop *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--kfa-color on the element or a parent.
Currently previewing #3b82f6.--kfa-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 16px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.