motion-reactive type
Map browser scroll velocity, or a normalized input you supply, to letter-spacing, variable-font axes, opacity, and CSS tilt. Use it for a scroll-reactive heading or an experiment with input-driven typography. This visual effect does not establish blur reduction or physical text stabilization.
Live demo — scroll this page, or use cursor / gyro
↕ Scroll this page to change the card styles
Scroll velocity can drive a visual change in typography. This demo maps input to weight, optical size, spacing, slant, and a CSS transform. The font must support an axis for its letterforms to change; the transform applies to the whole card.
Scroll this page and watch the card and style readout return toward rest after scrolling stops. Cursor mode maps screen position: the center is neutral and the corners increase the effect. That input remains active until you move back or exit. This demonstrates input mapping, not physical stabilization or improved reading.
How it works
Velocity in two dimensions
stabilType tracks both vertical and horizontal scroll velocity, each as a signed value — downscroll and rightscroll are positive; upscroll and leftscroll are negative. The combined magnitude drives font adaptation. The sign drives direction-specific tilt and lean.
Perspective compression + directional tilt
As speed increases, a CSS perspective() function tightens — the text plane compresses toward the viewer, like a dolly zoom. Simultaneously, rotateX and rotateY tilt the element in the direction of travel. Both effects decay the moment scrolling stops.
EMA smoothing blends input samples
Raw velocity signals are noisy. stabilType applies an exponential moving average before mapping velocity to type properties — so the typography transitions feel deliberate rather than jittery. The smoothing factor is tunable per element.
Runs in a rAF loop or on demand
startStabilType wires up a requestAnimationFrame loop and accepts a getVelocity callback — normalize your own input before passing it in. The library does not acquire device or head-tracking data. applyStabilType lets you drive it frame‑by‑frame from your own loop.
Usage
TypeScript + React · Vanilla JS
Drop-in component
"use client"
import { StabilTypeText } from '@overpunch/stabiltype'
// Controlled input: replace this prop with your own normalized value.
export default function Heading({ velocity = 0 }: { velocity?: number }) {
return <StabilTypeText velocity={velocity} opacityRange={[1, 1]}>
Heading text
</StabilTypeText>
}Hook — attach to any element
"use client"
import { useStabilType } from '@overpunch/stabiltype'
import { useRef } from 'react'
export default function Heading({ velocity = 0 }: { velocity?: number }) {
const ref = useRef<HTMLHeadingElement>(null)
useStabilType(ref, velocity, { weightRange: [300, 700], opacityRange: [1, 1] })
return <h1 ref={ref}>Heading text</h1>
}Vanilla JS — built-in scroll input
import { startStabilType } from '@overpunch/stabiltype/core'
const el = document.querySelector('h1')
// Built-in scroll listener — tracks both X and Y axes automatically
const stop = startStabilType(el, {
trackingRange: [0, 0.06], // explicit absolute range
weightRange: [300, 600],
opacityRange: [1, 1],
perspective: 600,
tilt: 3, // default
})
// Later: stop() cancels this instance and restores its stylesOptions
| Option | Default | Description |
|---|---|---|
| trackingRange | own spacing +0.06em | Letter-spacing range in em: [at rest, at max velocity]. |
| weightRange | own weight +300 | wght axis range: [at rest, at max velocity]. |
| opszRange | own optical size +12 | opsz axis range: [at rest, at max velocity]. |
| opacityRange | own opacity ×0.7 | Opacity range: [at rest, at max velocity]. |
| smoothing | 0.15 | EMA weight of the new sample per frame, 0–1. Higher = faster response (less lag); 1 snaps instantly; 0 freezes. |
| velocityMax | 15 | Scroll velocity in px/frame that maps to maximum typography adjustment. Only used by startStabilType in built-in scroll mode — applyStabilType and useStabilType expect a pre-normalised –1…+1 velocity and ignore this option. |
| weightAxis | 'wght' | Variable font weight axis tag. |
| opszAxis | 'opsz' | Variable font optical size axis tag. |
| perspective | 600 | CSS perspective depth in px at peak velocity. Tighter = more dramatic compression. 0 to disable. |
| tilt | 3 | rotateX/rotateY in degrees at peak velocity. Sign follows scroll direction. |
| slntRange | [8, -8] | slnt axis range: [at peak upscroll, at peak downscroll]. No-op on fonts without a slnt axis. |
| slntAxis | 'slnt' | Variable font slant axis tag. |
| liveBaseFVS | false | When false (default), font-variation-settings is read from the computed cascade once on activation and cached — eliminating a getComputedStyle() call per frame. Set to true only if external CSS dynamically changes font-variation-settings on the element after stabilType has started. |
| as | 'p' | HTML element to render. (StabilTypeText only) |
Accessibility
stabilType respects prefers-reduced-motion — when the user has requested reduced motion, startStabilType returns without installing the scroll listener or rAF loop, leaving the element unmodified. The React wrappers use the same guard; manual applyStabilType calls must handle this preference at the input source. Weight, tracking, and optical-size changes can rewrap text. The default opacity can reduce contrast; this demo holds opacity at 1. Load a variable font exposing the axes you use. Cursor mode maps position, and Gyro maps acceleration; neither validates physical motion compensation.
no-code
Use it in Webflow
The same effect, no build step — drop it straight into your design tool.
Webflow
One script tag, then mark any element with data-stabiltype. Configure it with data-* attributes.
<!-- Site Settings → Custom Code → Footer, or an Embed element -->
<script src="https://cdn.jsdelivr.net/npm/@overpunch/stabiltype/dist/stabiltype.webflow.min.js"></script>
<!-- Then add data-stabiltype to any text element -->
<h1 data-stabiltype>Your headline</h1>