Hero Inference
A large illustrative hero SVG for the inference-engineering motif — three FP32 blocks enter from the left, squeeze through a central funnel, and re-emerge on the right as smaller, brighter INT8 blocks while a throughput counter snaps from 1x to 4x. 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-inference.jsonUsage
import { HeroInference } from "@craft-bits/core/svg/hero-inference";
<HeroInference size={400} />
// Tint via the parent text color.
<div className="text-cb-accent">
<HeroInference />
</div>Understanding the component
- Continuous storyboard. A single
useEffectschedules the full ~8s cycle: entrance fade, FP32/INT8 labels appear, three blocks stagger through the funnel (large → small, base color → accent), a ghost block oscillates slowly on the left for speed contrast, the throughput counter snaps from1xto4x, fade, loop. Every timer is cleaned up on unmount and when reduced-motion changes. - Motion values, not re-renders. Each pipeline block's position, scale, color crossfade, and opacity are driven by
motion'suseMotionValue+useSpringso the React tree never re-renders during the loop. Springs come from@craft-bits/core/motion(SPRINGS.slowfor the pipeline traversal,SPRINGS.smoothfor shrinkage and crossfade,SPRINGS.bouncyfor the throughput counter). - Theme-driven color. The funnel strokes, base block fill, FP32 label, ghost block, axis, and caption all use
currentColor, so the host tints the whole illustration with anytext-cb-*utility. TheaccentColorprop tints the post-funnel blocks, squeeze glow, INT8 label, fast chevrons, and4xreadout — 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 — funnel + labels visible, three INT8 blocks parked on the right, throughput reading4x. No timers, noanimate()calls.
Variants / Examples
// Compact thumbnail.
<HeroInference size={200} />
// Explicit accent color.
<HeroInference size={480} accentColor="var(--color-accent-300)" />
// Custom hex.
<HeroInference 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 output blocks, squeeze glow, INT8 label, and throughput counter. |
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/HeroInference.tsx). - Inspiration: the compression-pipeline mental model — large, slow weights collapse into small, fast ones.