Velocity Marquee Free React component
An endless ticker that reacts to the scroll: scroll down and it races forward and leans into the motion, scroll up and it flips direction, stop and it eases back to its resting speed. Works for text, logos or anything else.
Get the code
npx shadcn@latest add https://alphenex.com/r/velocity-marquee.jsonWorks with any React project through the shadcn CLI. Prefer to paste it yourself? Copy the two files below into components/alphenex/. No Tailwind or animation library needed.
import VelocityMarquee from '@/components/alphenex/velocity-marquee';
<VelocityMarquee items={['Design', 'Build', 'Launch']} />'use client';
import { useEffect, useRef } from 'react';
import './velocity-marquee.css';
const DEFAULT_ITEMS = ['Motion', 'Next.js', 'Three.js', 'Shopify', 'SEO', 'Scroll', 'Design', 'Speed'];
/**
* VelocityMarquee
* An endless ticker that speeds up and leans when the page scrolls. Scroll
* down and it races forward; scroll up and it flips direction. It eases back
* to its normal speed when the scrolling stops.
*
* Free from Alphenex Lab: https://alphenex.com/lab/velocity-marquee (MIT)
*/
export default function VelocityMarquee({
items = DEFAULT_ITEMS,
speed = 70, // resting speed, px per second
boost = 6, // how much scroll speed adds to the motion
maxSkew = 14, // strongest lean in degrees
separator = '✦',
pauseOnHover = false,
renderItem,
className = '',
style,
...props
}) {
const rootRef = useRef(null);
const trackRef = useRef(null);
useEffect(() => {
const root = rootRef.current;
const track = trackRef.current;
if (!root || !track || window.matchMedia('(prefers-reduced-motion: reduce)').matches) return undefined;
let x = 0;
let velocity = 0; // smoothed scroll speed, px per frame
let direction = 1;
let lastScroll = window.scrollY;
let last = performance.now();
let visible = false;
let hovered = false;
let frame = 0;
const loop = (now) => {
const dt = Math.min(0.05, (now - last) / 1000);
last = now;
const scrolled = window.scrollY - lastScroll;
lastScroll = window.scrollY;
velocity += (scrolled - velocity) * 0.12;
if (Math.abs(scrolled) > 0.5) direction = scrolled > 0 ? 1 : -1;
const copy = track.firstElementChild?.offsetWidth || 1;
const pace = hovered ? 0 : speed + Math.abs(velocity) * boost * 10;
x -= pace * dt * direction;
x = ((x % copy) - copy) % copy; // keep x in (-copy, 0] so the loop is seamless
const skew = Math.max(-maxSkew, Math.min(maxSkew, velocity * 0.6));
track.style.transform = `translate3d(${x}px, 0, 0) skewX(${-skew}deg)`;
frame = visible ? requestAnimationFrame(loop) : 0;
};
const observer = new IntersectionObserver(([entry]) => {
visible = entry.isIntersecting;
if (visible && !frame) {
last = performance.now();
lastScroll = window.scrollY;
frame = requestAnimationFrame(loop);
}
});
observer.observe(root);
const enter = () => { hovered = pauseOnHover; };
const leave = () => { hovered = false; };
root.addEventListener('pointerenter', enter);
root.addEventListener('pointerleave', leave);
return () => {
observer.disconnect();
cancelAnimationFrame(frame);
root.removeEventListener('pointerenter', enter);
root.removeEventListener('pointerleave', leave);
};
}, [speed, boost, maxSkew, pauseOnHover]);
const group = (copy) => (
<div className="alx-marquee__group" aria-hidden={copy > 0 || undefined} key={copy}>
{items.map((item, i) => (
<span className="alx-marquee__item" key={`${copy}-${i}`}>
{renderItem ? renderItem(item, i) : item}
{separator && <span className="alx-marquee__sep" aria-hidden="true">{separator}</span>}
</span>
))}
</div>
);
return (
<div ref={rootRef} className={`alx-marquee ${className}`} style={style} {...props}>
{/* Three copies: one on screen, one either side, so the loop never shows a gap. */}
<div ref={trackRef} className="alx-marquee__track">
{[0, 1, 2].map(group)}
</div>
</div>
);
}
/* VelocityMarquee, Alphenex Lab (MIT) */
.alx-marquee {
position: relative;
overflow: hidden;
width: 100%;
user-select: none;
}
.alx-marquee__track {
display: flex;
width: max-content;
will-change: transform;
}
.alx-marquee__group {
display: flex;
flex-shrink: 0;
}
.alx-marquee__item {
display: inline-flex;
align-items: center;
gap: 0.6em;
padding-right: 0.6em;
white-space: nowrap;
font-size: clamp(2rem, 7vw, 5rem);
font-weight: 800;
line-height: 1.1;
letter-spacing: -0.04em;
}
.alx-marquee__sep {
font-size: 0.5em;
opacity: 0.45;
}
Paste this into Claude, ChatGPT, Cursor, Lovable or v0 to build it from scratch.
Build a React "VelocityMarquee" component with no libraries. Render the items three times in a row inside a flex track so the loop never shows a gap. On every animation frame, move the track left by speed px per second, plus extra speed from the smoothed window scroll velocity (scroll delta per frame, eased with a factor of 0.12, times a boost prop). Scrolling up flips the direction. Wrap the x position by the width of one copy so it loops seamlessly. Lean the track with skewX based on the velocity, clamped to maxSkew degrees. Only run the loop while the marquee is on screen (IntersectionObserver). Props: items, speed, boost, maxSkew, separator, pauseOnHover, renderItem. Mark the duplicate copies aria-hidden. Show it still for prefers-reduced-motion.How the velocity marquee works
The items are rendered three times side by side. The track moves left a little on every animation frame, and when it has travelled the width of one copy it jumps back by exactly that width. The copies are identical, so the jump is invisible and the ticker never ends.
Scroll speed is read on every frame from the change in window.scrollY and smoothed, so the ticker accelerates and decelerates instead of jerking. The same value sets the lean with skewX, and the scroll direction decides which way the ticker runs.
The loop only runs while the marquee is on screen, and the two duplicate copies are hidden from screen readers so the items are announced once.
Frequently asked questions
Want motion like this on your website?
We design and build custom websites with motion, 3D and SEO built in. Websites from $500.