React Scroll Velocity Text
Dynamic scrolling text that responds to scroll velocity. Perfect for React applications requiring engaging scroll-based animations.
Powered by
Trying to implement scroll-based animations?
Join our Discord community for help from other developers.
Most scrolling text effects are basic marquees with constant speed—predictable animations that don't respond to user interaction. This component creates dynamic text that moves based on actual scroll velocity, speeding up and changing direction based on how fast users scroll. The text responds naturally to scroll patterns, creating an engaging parallax effect.
Scroll velocity-based text animation
Text that dynamically responds to scroll speed and direction:
Built with TypeScript and Motion for React applications, using scroll velocity tracking and spring physics. The component alternates text direction and adjusts speed based on real-time scroll velocity calculations, creating smooth, responsive animations.
Installation
npx shadcn@latest add https://www.shadcn.io/registry/scroll-velocity.json
npx shadcn@latest add https://www.shadcn.io/registry/scroll-velocity.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/scroll-velocity.json
bunx shadcn@latest add https://www.shadcn.io/registry/scroll-velocity.json
Usage
import ScrollVelocity from "@/components/text/scroll-velocity";
<ScrollVelocity
texts={['React Components', 'Scroll Down']}
velocity={100}
className="text-foreground"
/>
Why most scrolling text is boring
Most developers use basic CSS animations or simple marquees—constant-speed text that ignores user behavior. These effects feel disconnected from the scrolling experience, running at fixed speeds regardless of how users interact with the page.
This React component uses Motion's scroll velocity tracking to create text that genuinely responds to scroll behavior. When users scroll fast, text moves faster. When they scroll up, text can reverse direction. The spring physics create natural-feeling acceleration and deceleration that matches scroll patterns.
The key insight: scroll velocity creates intuitive interaction. When text speed matches scroll intensity, it feels like the content is physically connected to the scroll action, creating a more immersive and engaging experience.
Features
- Real-time scroll velocity tracking with configurable sensitivity and spring physics
- Alternating text direction for visual variety and dynamic composition effects
- Customizable velocity mapping with input/output ranges for fine-tuned responsiveness
- Spring-based smooth velocity transitions with configurable damping and stiffness
- Multiple text lines with independent velocity and direction control
- Performance optimized with Motion's useAnimationFrame and element width caching
- Free open source component compatible with Next.js and shadcn/ui design systems
API Reference
ScrollVelocity
Scroll-responsive text animation component with velocity-based movement.
Prop | Type | Default | Description |
---|---|---|---|
texts | string[] | required | Array of text strings to animate |
velocity | number | 100 | Base velocity for text movement |
scrollContainerRef | RefObject<HTMLElement> | - | Container element for scroll tracking |
className | string | - | CSS classes for text styling |
damping | number | 50 | Spring damping for velocity smoothing |
stiffness | number | 400 | Spring stiffness for velocity response |
numCopies | number | 6 | Number of text copies for seamless loop |
velocityMapping | VelocityMapping | {input: [0, 1000], output: [0, 5]} | Velocity sensitivity configuration |
parallaxClassName | string | - | CSS classes for parallax container |
scrollerClassName | string | - | CSS classes for scrolling text element |
parallaxStyle | CSSProperties | - | Inline styles for parallax container |
scrollerStyle | CSSProperties | - | Inline styles for scrolling text |
Velocity Mapping Configuration
Fine-tune scroll responsiveness with velocity mapping:
Setting | Example Value | Effect |
---|---|---|
Sensitive | {input: [0, 500], output: [0, 8]} | High responsiveness to scroll |
Moderate | {input: [0, 1000], output: [0, 5]} | Balanced scroll response |
Subtle | {input: [0, 2000], output: [0, 3]} | Gentle scroll effects |
Spring Physics Options
Control animation smoothness with spring configuration:
Parameter | Low Value | High Value | Effect |
---|---|---|---|
Damping | 20 (bouncy) | 100 (smooth) | Controls oscillation |
Stiffness | 200 (slow) | 800 (fast) | Controls response speed |
Common gotchas
Text doesn't move smoothly: Adjust the damping and stiffness values to control spring physics. Higher damping reduces bouncing, while higher stiffness increases responsiveness. Test different combinations for your desired feel.
Velocity mapping feels wrong: The input range should match your typical scroll velocities, while output range controls effect intensity. Use browser dev tools to log actual scroll velocities and adjust mapping accordingly.
Performance issues on mobile: The component uses requestAnimationFrame for smooth animation. On slower devices, consider reducing numCopies or using a custom scroll container to limit the scroll tracking area.
Text appears cut off: Ensure the container has proper overflow handling and sufficient width. The component creates multiple text copies for seamless looping, so container width affects the loop point.
Direction changes feel abrupt: The component reverses direction based on scroll velocity sign. For gentler transitions, consider adjusting the velocity mapping or adding custom transition logic.
Integration with other components
Perfect for hero sections with Card layouts or dynamic headers in Sheet overlays. Works excellently as background elements in Dialog modals or attention-grabbing sections in Tabs interfaces.
For landing pages, combine with Badge components for feature highlights or Button components in call-to-action sections. The component integrates seamlessly with Progress indicators and works well within Separator sections for visual breaks.
Questions developers actually ask
React Rotating Text
React rotating text with smooth vertical transitions. Cycle through multiple phrases with clean animations using Motion, TypeScript, and shadcn/ui for Next.js apps.
React Shimmering Text
React shimmering text with smooth wave animations. Character-by-character shimmer effects built with Motion, TypeScript, and shadcn/ui for Next.js apps.