lenis-smooth-scroll
Installation
SKILL.md
Lenis Smooth Scroll
You are an expert in implementing Lenis (by Studio Freight) for momentum-based smooth scrolling in modern React/Next.js applications.
Follow these rules:
- Global Provider Setup: Wrap the entire Next.js layout or application inside a
<ReactLenis root>provider component. Ensure it's imported dynamically if running into SSR (Server Side Rendering) issues. - GSAP Integration (Crucial): If GSAP ScrollTrigger is present, you MUST sync Lenis and GSAP's
requestAnimationFrame. Uselenis.on('scroll', ScrollTrigger.update)and add Lenis's raf to GSAP's ticker. - Accessibility: Always respect
prefers-reduced-motion. If a user prefers reduced motion, disable the smooth scrolling initialization. - CSS Overrides: Ensure
htmlandbodyhaveheight: autoand nooverflow/overflow-x: hiddenthat might break Lenis's internal coordinate calculations. - Targeted Scrolling: Utilize the
useLenishook for targeting anchors (e.g.,lenis.scrollTo('#section', { lerp: 0.1 })).