Hero Modern Arch
A large illustrative hero SVG that animates the "modern transformer architectures" motif — five stacked layer bars on the left, five tokens that fly into a KV cache column on the right, and two memory bars at the bottom contrasting the linear-in-n footprint (with cache) against the quadratic n-squared blow-up (without cache). Theme-driven via currentColor and a single accentColor prop; reduced-motion users see a static end state.
Customize
Hero illustration
400px
accent
false
Installation
npx shadcn@latest add https://craftbits.dev/r/hero-modern-arch.jsonUsage
import { HeroModernArch } from "@craft-bits/core/svg/hero-modern-arch";
<HeroModernArch size={400} />
// Tint via the parent text color.
<div className="text-cb-accent">
<HeroModernArch />
</div>Understanding the component
- Continuous storyboard. A single
useEffectschedules the full ~9s cycle: scene fades in, five layer bars stagger in, the cache outline appears, then five tokens generate one per second — each pops above the model, flies into the cache, and increments the linear memory bar. At 5.8s the quadratic bar reveals dramatically (animating to 25 units with a warning-glow overlay), the comparison holds, then everything fades and the loop restarts. Every timer is cleaned up on unmount and when reduced-motion changes. - Motion values, not re-renders. Token positions, opacities, cache fills, and memory-bar widths are driven by
motion'suseMotionValue+useSpring, so the React tree never re-renders during the loop. Springs come from@craft-bits/core/motion—SPRINGS.smoothfor entrances,SPRINGS.bouncyfor token cubes and the quadratic reveal,SPRINGS.snapfor token flights,SPRINGS.slowfor the linear memory bar. - Theme-driven color. Layer bars, "model" / "KV cache" labels, cache outline, and caption use
currentColor, so the host tints the base illustration with anytext-cb-*utility. TheaccentColorprop colors the cache blocks, flying tokens, both memory bars, and the warning-glow overlay — any CSS color (includingvar(--color-accent-500)). - Reduced-motion safe. When
prefers-reduced-motion: reduceis set, or thepausedprop istrue, the loop short-circuits to a single static end state: all five layers visible, the cache filled, both memory bars at their final widths (linear at n=5, quadratic at 25).
Variants / Examples
// Paused — useful for thumbnails / OG images.
<HeroModernArch paused />
// Compact thumbnail.
<HeroModernArch size={200} />
// Explicit accent color.
<HeroModernArch size={480} accentColor="var(--color-accent-300)" />
// Custom hex.
<HeroModernArch accentColor="#8b5cf6" />Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | number | 400 | Pixel width. Height is computed from the 400×280 aspect ratio. |
accentColor | string | 'currentColor' | Any CSS color. Tints the cache blocks, flying tokens, both memory bars, and the warning-glow overlay. |
paused | boolean | false | When true, render a single static end state instead of looping. |
className | string | — | Extra classes merged onto the root <svg>. |
...rest | SVGAttributes<SVGSVGElement> | — | Other SVG props forwarded to the root. |
Accessibility
- The root
<svg>carriesaria-hidden="true"— the illustration is decorative; pair it with a visible heading or caption in its surrounding context. - Motion respects
prefers-reduced-motion: reduce: the loop short-circuits and renders a static end state. - All colors flow from
currentColor+ theaccentColorprop, so contrast tracks the consumer's text and accent tokens — no hardcoded hex values.
Credits
- Extracted from:
craftingattention(app/src/lessons/primitives/chrome/icons/heroes/HeroModernArch.tsx). - Inspiration: "same idea, faster pen" — the modern KV-cache trick that turns autoregressive decoding from quadratic to linear.