AI CSS Animations

Cache Hit Grid

Lookups drop onto a 3 by 3 grid of isometric cache cells and each hit lights its cell in the accent before fading back, three cells in turn. Hairline SVG with CSS translate and fill.

Also known as: cache hit animation, isometric grid animation, hairline isometric.

HTML

<div class="hln-cache-hit" role="img" aria-label="Requests hitting cached cells">
  <svg viewBox="-110 -60 220 120" aria-hidden="true"><g transform="translate(0 2) scale(1.7)"><g><polygon points="-38,0 0,19 0,17 -38,-2"/><polygon points="38,0 0,19 0,17 38,-2"/><polygon points="0,-21 38,-2 0,17 -38,-2"/></g><g><g><polygon points="-9,-14 0,-9.5 0,-15.5 -9,-20"/><polygon points="9,-14 0,-9.5 0,-15.5 9,-20"/><polygon points="0,-24.5 9,-20 0,-15.5 -9,-20"/></g></g><g class="hln-cache-hit-cell" style="--d: 2s"><g><polygon points="-21,-8 -12,-3.5 -12,-9.5 -21,-14"/><polygon points="-3,-8 -12,-3.5 -12,-9.5 -3,-14"/><polygon points="-12,-18.5 -3,-14 -12,-9.5 -21,-14"/></g></g><g><g><polygon points="3,-8 12,-3.5 12,-9.5 3,-14"/><polygon points="21,-8 12,-3.5 12,-9.5 21,-14"/><polygon points="12,-18.5 21,-14 12,-9.5 3,-14"/></g></g><g><g><polygon points="-33,-2 -24,2.5 -24,-3.5 -33,-8"/><polygon points="-15,-2 -24,2.5 -24,-3.5 -15,-8"/><polygon points="-24,-12.5 -15,-8 -24,-3.5 -33,-8"/></g></g><g><g><polygon points="-9,-2 0,2.5 0,-3.5 -9,-8"/><polygon points="9,-2 0,2.5 0,-3.5 9,-8"/><polygon points="0,-12.5 9,-8 0,-3.5 -9,-8"/></g></g><g class="hln-cache-hit-cell hln-cache-hit-first" style="--d: 0s"><g><polygon points="15,-2 24,2.5 24,-3.5 15,-8"/><polygon points="33,-2 24,2.5 24,-3.5 33,-8"/><polygon points="24,-12.5 33,-8 24,-3.5 15,-8"/></g></g><g class="hln-cache-hit-cell" style="--d: 4s"><g><polygon points="-21,4 -12,8.5 -12,2.5 -21,-2"/><polygon points="-3,4 -12,8.5 -12,2.5 -3,-2"/><polygon points="-12,-6.5 -3,-2 -12,2.5 -21,-2"/></g></g><g><g><polygon points="3,4 12,8.5 12,2.5 3,-2"/><polygon points="21,4 12,8.5 12,2.5 21,-2"/><polygon points="12,-6.5 21,-2 12,2.5 3,-2"/></g></g><g><g><polygon points="-9,10 0,14.5 0,8.5 -9,4"/><polygon points="9,10 0,14.5 0,8.5 9,4"/><polygon points="0,-0.5 9,4 0,8.5 -9,4"/></g></g><g class="hln-cache-hit-pkt" style="animation-delay: 0s"><g><polygon points="21,-8 24,-6.5 24,-9.5 21,-11"/><polygon points="27,-8 24,-6.5 24,-9.5 27,-11"/><polygon points="24,-12.5 27,-11 24,-9.5 21,-11"/></g></g><g class="hln-cache-hit-pkt" style="animation-delay: 2s"><g><polygon points="-15,-14 -12,-12.5 -12,-15.5 -15,-17"/><polygon points="-9,-14 -12,-12.5 -12,-15.5 -9,-17"/><polygon points="-12,-18.5 -9,-17 -12,-15.5 -15,-17"/></g></g><g class="hln-cache-hit-pkt" style="animation-delay: 4s"><g><polygon points="-15,-2 -12,-0.5 -12,-3.5 -15,-5"/><polygon points="-9,-2 -12,-0.5 -12,-3.5 -9,-5"/><polygon points="-12,-6.5 -9,-5 -12,-3.5 -15,-5"/></g></g></g></svg>
</div>

CSS

.hln-cache-hit {
  --c: var(--hln-color, #ff4f2e);
  font-size: var(--hln-size, 16px);
  position: relative;
  display: grid;
  place-items: center;
  width: 22em;
  height: 12em;
  border-radius: 0.75em;
  background: #f6f5f1;
  overflow: hidden;
  --u: 1px;
}
.hln-cache-hit svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: #ffffff;
  stroke: #1c1d21;
  stroke-width: 1.25;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.hln-cache-hit svg * {
  vector-effect: non-scaling-stroke;
}
.hln-cache-hit .hln-cache-hit-cell polygon:last-child {
  animation: hln-cache-hit-hit 6s var(--d) infinite;
}
.hln-cache-hit .hln-cache-hit-pkt {
  opacity: 0;
  animation: hln-cache-hit-drop 6s infinite;
}
.hln-cache-hit .hln-cache-hit-pkt polygon {
  fill: var(--c);
}
@keyframes hln-cache-hit-drop {
  0% { opacity: 0; translate: 0 calc(-15 * var(--u)); }
  2% { opacity: 1; translate: 0 calc(-15 * var(--u)); animation-timing-function: cubic-bezier(0.55, 0, 0.85, 0.35); }
  12% { opacity: 1; translate: 0 0; animation-timing-function: ease-in; }
  15%, 100% { opacity: 0; translate: 0 calc(2 * var(--u)); }
}
@keyframes hln-cache-hit-hit {
  0%, 11.5% { fill: #ffffff; }
  13%, 22% { fill: var(--c); }
  34%, 100% { fill: #ffffff; }
}
@media (prefers-reduced-motion: reduce) {
  .hln-cache-hit * {
    animation: none !important;
  }
  .hln-cache-hit .hln-cache-hit-first polygon:last-child { fill: var(--c); }
}

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

Customizing this snippet

  • Color: set --hln-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --hln-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 hairline animations