AI CSS Animations

Staggered List Entrance

List rows slide up and fade in one after another. Each row carries its index in a --i custom property and the delay is calc(var(--i) * 90ms), so adding rows needs no new CSS.

Also known as: css staggered animation, list items animate one by one, stagger animation delay css.

HTML

<ul class="kfa-staggered-list-entrance"><li style="--i: 0; --w: 82%"><span class="kfa-staggered-list-entrance-dot"></span><span class="kfa-staggered-list-entrance-line"></span></li><li style="--i: 1; --w: 64%"><span class="kfa-staggered-list-entrance-dot"></span><span class="kfa-staggered-list-entrance-line"></span></li><li style="--i: 2; --w: 74%"><span class="kfa-staggered-list-entrance-dot"></span><span class="kfa-staggered-list-entrance-line"></span></li><li style="--i: 3; --w: 52%"><span class="kfa-staggered-list-entrance-dot"></span><span class="kfa-staggered-list-entrance-line"></span></li></ul>

CSS

.kfa-staggered-list-entrance {
  --c: var(--kfa-color, #3b82f6);
  font-size: var(--kfa-size, 16px);
  display: grid;
  gap: 0.45em;
  width: 13em;
  margin: 0;
  padding: 0;
  list-style: none;
}
.kfa-staggered-list-entrance > li {
  display: flex;
  align-items: center;
  gap: 0.7em;
  height: 1.8em;
  padding: 0 0.6em;
  border-radius: 0.55em;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  animation: kfa-staggered-list-entrance-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) calc(var(--i) * 90ms) both;
}
.kfa-staggered-list-entrance-dot {
  flex: none;
  width: 0.9em;
  height: 0.9em;
  border-radius: 50%;
  background: var(--c);
}
.kfa-staggered-list-entrance-line {
  width: var(--w);
  height: 0.45em;
  border-radius: 1em;
  background: color-mix(in srgb, var(--c) 45%, transparent);
}
@keyframes kfa-staggered-list-entrance-in {
  from { opacity: 0; transform: translateY(1em) scale(0.97); }
}

@media (prefers-reduced-motion: reduce) {
  .kfa-staggered-list-entrance, .kfa-staggered-list-entrance *, .kfa-staggered-list-entrance::before, .kfa-staggered-list-entrance::after, .kfa-staggered-list-entrance *::before, .kfa-staggered-list-entrance *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --kfa-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --kfa-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar keyframe animations