Hero Neural Nets
A large illustrative hero SVG that animates a forward pass through a tiny 3-4-2 fully connected network. Pulses of light travel left-to-right through the connections, and each layer's nodes light up with a bouncy spring as the signal arrives. Theme-driven via currentColor + 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-neural-nets.jsonUsage
import { HeroNeuralNets } from "@craft-bits/core/svg/hero-neural-nets";
<HeroNeuralNets size={400} />
// Tint via the parent text color.
<div className="text-cb-accent">
<HeroNeuralNets />
</div>Understanding the component
- Continuous storyboard. A single
useEffectschedules the full ~6s cycle: nodes fade in with stagger, lines fade in, input layer fires, input→hidden connections brighten, hidden layer activates and input cools, hidden→output connections brighten, output layer pops with a scale bounce, output resets, loop. Every timer is cleaned up on unmount and when reduced-motion changes. - Motion values, not re-renders. All 9 nodes and 20 connections are driven by
motion'suseMotionValue+useSpringso the React tree never re-renders during the loop. Springs come from@craft-bits/core/motion—SPRINGS.bouncyfor layer activations,SPRINGS.snapfor connection pulses,SPRINGS.slowfor the entrance fade. - Theme-driven colour. Surface, node base, border, and caption use
cb-*tokens. TheaccentColorprop colours the active node glow, connection pulses, and the radial backdrop behind the hidden layer — any CSS colour, includingvar(--color-accent-500). - Reduced-motion safe. When
prefers-reduced-motion: reduceis set (orpausedistrue), the loop short-circuits to a single static end state: every node painted, output nodes gently glowing, connections dimly visible.
Variants / Examples
// Compact thumbnail.
<HeroNeuralNets size={200} />
// Paused — useful for OG images.
<HeroNeuralNets paused />
// Custom hex.
<HeroNeuralNets accentColor="#8b5cf6" />Props
| Prop | Type | Default | Description |
|---|---|---|---|
accentColor | string | 'currentColor' | Any CSS colour. Tints the active node glow, connection pulses, and backdrop. |
size | number | — | Optional fixed pixel width. Omit to fill the parent. Height tracks the 400x280 aspect ratio. |
paused | boolean | false | When true, render the 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. Thepausedprop offers a manual escape hatch. - All colours flow from
currentColorplus 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/HeroNeuralNets.tsx). - Inspiration: classic forward-pass diagrams — a neuron is a tiny decision-maker.