Hero CNNs
A large illustrative hero SVG that animates the core CNN motif — a 3×3 kernel sliding across a 6×6 input grid, filling a 4×4 output feature map on a continuous loop. Theme-driven via currentColor + a single accentColor prop; reduced-motion users see a static end state.
Customize
Hero illustration
400px
accent
Installation
npx shadcn@latest add https://craftbits.dev/r/hero-cnns.jsonUsage
import { HeroCNNs } from "@craft-bits/core/svg/hero-cnns";
<HeroCNNs size={400} />
// Tint via the parent text color.
<div className="text-cb-accent">
<HeroCNNs />
</div>Understanding the component
- Continuous storyboard. A single
useEffectschedules the full ~8s cycle: input grid fade-in, kernel appears, output grid fade-in, kernel scans 16 positions, brief hold, output pulse, fade, loop. Every timer is cleaned up on unmount and when reduced-motion changes. - Motion values, not re-renders. All 36 input highlights and 16 output cells are driven by
motion'suseMotionValue+useSpringso the React tree never re-renders during the loop. Springs come from@craft-bits/core/motion(SPRINGS.snap,SPRINGS.smooth,SPRINGS.bouncy). - Theme-driven color. Base grid, borders, labels, and caption use
currentColor, so the host tints the whole illustration with anytext-cb-*utility. TheaccentColorprop colors the kernel, glow, output cells, connection line, and pulse — any CSS color (includingvar(--color-accent-500)). - Reduced-motion safe. When
prefers-reduced-motion: reduceis set, the loop short-circuits to a static end state: kernel parked at the top-left, output fully filled, connection line hidden.
Variants / Examples
// Compact thumbnail.
<HeroCNNs size={200} />
// Explicit accent color.
<HeroCNNs size={480} accentColor="var(--color-accent-300)" />
// Custom hex.
<HeroCNNs 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 kernel, glow, output cells, connection line, and pulse. |
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/HeroCNNs.tsx). - Inspiration: classic CNN feature-map slides — local weights, repeated.