Hero Vec S4
A retro CRT oscilloscope on a phosphor grid: Wave A holds steady, Wave B drifts continuously around the unit circle, and the screen's radial glow plus a tabular dot-product readout track the cosine of the phase difference in real time. Theme-driven via currentColor plus a single accentColor prop; reduced-motion users see the aligned-peak frame statically.
Customize
Oscilloscope hero
400px
accent
false
Installation
npx shadcn@latest add https://craftbits.dev/r/hero-vec-s4.jsonUsage
import { HeroVecS4 } from "@craft-bits/core/svg/hero-vec-s4";
<HeroVecS4 size={400} />
// Tint via the parent text color.
<div className="text-cb-accent">
<HeroVecS4 />
</div>Understanding the component
- Continuous storyboard. A single
useEffectschedules the full cycle: the CRT bezel breathes opacity gently, both waves draw in viapathLengthsprings (Wave A at 0.4s, Wave B at 0.8s), and at 1.4s the phase begins a linear drift through one full turn every 6 seconds — repeating forever until the component unmounts or reduced-motion flips. - Motion values, not re-renders. The phase is a
useMotionValue; auseTransformderivescos(phase), another derives the absolute value for the glow, and a dampeduseSpringsmooths the result. ArequestAnimationFrameloop reads the phase each frame and writes the new Wave Bdattribute plus the live dot-product text, so the React tree never re-renders during the drift. Springs come from@craft-bits/core/motion—SPRINGS.slowfor the entrance,SPRINGS.dampedfor the glow. - Theme-driven color. Bezel, grid lines, Wave A, formula label, and caption all use
currentColor, so the host tints the structural chrome with anytext-cb-*utility. TheaccentColorprop colors the drifting Wave B, the radial alignment glow, and the dot-product readout — any CSS color (includingvar(--cb-accent)). - Reduced-motion safe. When
prefers-reduced-motion: reduceis set, or thepausedprop istrue, the loop short-circuits to a single static frame: both waves aligned at phase 0, glow at peak intensity, dot-product readout pinned at1.00.
Variants / Examples
// Paused — useful for thumbnails / OG images.
<HeroVecS4 paused />
// Compact thumbnail.
<HeroVecS4 size={200} />
// Explicit accent color.
<HeroVecS4 size={480} accentColor="var(--cb-accent)" />
// Custom hex.
<HeroVecS4 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 drifting Wave B, alignment glow, and dot-product readout. |
paused | boolean | false | When true, render a single static frame (aligned waves, peak glow) 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 carries
aria-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 aligned frame. - All colors 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/HeroVecS4.tsx). - Inspiration: retro CRT oscilloscope showing two sine waves — "when waves agree, the product peaks".