Category: Typography · Interaction: cursor proximity · Stack: vanilla JS (GSAP optional), any variable font
Prompt
Build a full-screen hero headline where each letter's font weight reacts to how close the cursor is, using a variable font.
Look and feel
- Choose your own pairing. For example, a dark background (
#101418) with a pale accent colour for the type, or my brand palette. - Use a variable display font with a wide weight axis (for example Anybody, Fraunces, Recursive or Big Shoulders, at least 100–900). Uppercase or title case, very large and fluid (
clamp()from about 3.5rem to 11rem), tight line-height. - A 2–3 line headline with my own words. Give one or two words a different base weight (one light, one medium) so the contrast is visible before any interaction.
Behaviour
- Split the headline into individual letters, but lock the line breaks first so lines never re-wrap as weights change.
- Each letter has a base weight and an opposite "reaction" weight: heavy letters get lighter near the cursor and light letters get heavier.
- Within a radius of about 250–350px around the cursor, blend each letter from its base weight toward its reaction weight according to distance, so the closest letters change most.
- Ease the weight changes smoothly with a frame-rate-independent lerp (consistent on 60Hz and 120Hz screens). When the cursor leaves, everything eases back.
- Measure letter positions once and on resize, not every frame, to avoid jitter as glyph widths change. Only touch the DOM when a letter's rounded weight changes.
Accessibility and devices
- Keep the headline as one real heading for screen readers (hide the split spans from assistive technology or use an
aria-label). - With
prefers-reduced-motion, show the static headline. - On touch, optionally run the effect while the finger is dragging, or not at all.
Deliverable: a small, dependency-light module with a config object (radius, smoothing, weights) and an init function that takes any heading element.