BosskuAI Lenis Smooth Scroll
Use this skill when the task involves Lenis smooth scrolling: installing it, wiring it into a framework, syncing it with GSAP, debugging scroll jank, supporting anchors, handling nested scroll areas, using lenis/snap, or reviewing whether smooth scrolling is appropriate.
How this differs from nearby skills
bosskuai-gsap-animation: owns GSAP timelines and ScrollTrigger behavior. Load both when Lenis drives scroll and GSAP reacts to it.
bosskuai-ui-ux-design-to-code: owns UX and accessibility decisions. Use both when smooth scroll changes navigation, focus, or reduced-motion behavior.
bosskuai-3d-web-development: owns WebGL and 3D scroll choreography. Use Lenis here only for the scroll layer.
bosskuai-performance-profiling: load when scroll performance is the main defect.
- GSAP ScrollSmoother (free with GSAP's no-charge license): an alternative smoother; pick one, never both.
Source posture
This skill was shaped from the upstream Lenis package (check package.json in your project for the pinned version). Prefer official Lenis docs when exact options or exports matter. The installed version is in the lockfile or node_modules/lenis/package.json, and the latest is npm view lenis version. Options and exports change between versions, so read the README in node_modules/lenis/ before you use one.
Mindset
- Smooth scrolling is infrastructure for an experience, not a default upgrade.
- Native scroll semantics, focus behavior, anchors, modals, and nested scroll areas must keep working.
- Use one RAF owner. When GSAP is present, wire Lenis into GSAP ticker instead of running competing loops.
- CSS setup matters. Missing Lenis CSS often creates subtle behavior bugs.
- Touch behavior, iframes, sticky elements, and route transitions deserve extra scrutiny.
Workflow
Phase 1 - Decide whether Lenis is appropriate
- Identify the scroll job: general smoothing, scroll-linked animation, WebGL sync, parallax, horizontal, infinite, anchors, snap, or modal/nested scroll support.
- Check accessibility and UX risks: reduced motion, keyboard navigation, focus jumps, anchor links, browser history, and native mobile feel.
- Read existing scroll code before adding Lenis. Do not stack it on top of another smooth-scroll library.
Phase 2 - Integrate
- Install/import from
lenis; import lenis/dist/lenis.css or confirm equivalent CSS is present.
- For simple vanilla use, prefer
autoRaf: true.
- For GSAP ScrollTrigger or custom animation clocks, set
autoRaf: false, call lenis.raf(time), and clean up ticker callbacks.
- For React, use
ReactLenis and useLenis from lenis/react.
- For Vue, use
VueLenis and useLenis from lenis/vue; for Nuxt, configure modules: ['lenis/nuxt'].
- For anchors, nested scroll, horizontal, snap, or infinite scroll, configure those intentionally rather than copying a catch-all setup.
Phase 3 - Debug and harden
- Confirm scroll events, progress, direction, velocity, and target scroll behave as expected.
- Recalculate dimensions when content changes if auto resize is disabled or dynamic layout confuses measurements.
- Use the
data-lenis-prevent attribute (or the prevent option) for modals and other native-scroll areas; use allowNestedScroll only when the performance tradeoff is acceptable.
- Sync ScrollTrigger with Lenis by updating ScrollTrigger on Lenis scroll and driving Lenis from GSAP ticker.
- On teardown, call
destroy() or unmount the provider cleanly, remove ticker callbacks, and stop custom RAF loops. When a modal locks the page, call lenis.stop() on open and lenis.start() on every close path (button, Escape, route change); a missed start() leaves the page frozen.
- Verify reduced motion, mobile touch, keyboard focus, anchor links, modals, route changes, and back and forward navigation (the restored scroll position should appear without a glide), on the longest real page. Lenis already disables smoothing under
prefers-reduced-motion; confirm that in the installed version's README rather than re-implementing it.
Common patterns
import Lenis from 'lenis'
import 'lenis/dist/lenis.css'
const lenis = new Lenis({ autoRaf: true })
lenis.on('scroll', ({ scroll, progress, velocity }) => {
// wire only the state you need
})
import Lenis from 'lenis'
import gsap from 'gsap'
import { ScrollTrigger } from 'gsap/ScrollTrigger'
gsap.registerPlugin(ScrollTrigger)
const lenis = new Lenis({ autoRaf: false })
lenis.on('scroll', ScrollTrigger.update)
const tick = (time) => lenis.raf(time * 1000) // named so teardown can remove it
gsap.ticker.add(tick)
gsap.ticker.lagSmoothing(0)
// teardown: gsap.ticker.remove(tick); lenis.destroy()
Guardrails
- Do not add Lenis when the page only needs native scroll and a tiny transition.
- Do not break anchors, focus, modals, or nested scroll areas for visual smoothness.
- Do not use multiple independent RAF loops for Lenis plus GSAP.
- Do not enable heavy options like broad nested-scroll detection without checking performance.
- Do not forget cleanup in SPAs, route transitions, and component unmounts.
- Do not test a smooth scroll with a fixed sleep. Wait until the scroll position stops changing.
Output format
Lenis scroll summary:
Scroll job: [smooth / GSAP sync / horizontal / snap / infinite / nested]
Runtime: [vanilla / React / Vue / Nuxt]
RAF owner: [autoRaf / custom RAF / GSAP ticker]
Accessibility fallback: [reduced motion / native scroll / static]
Implementation plan:
Setup: [imports, CSS, provider or instance]
Options: [only options that matter]
Integration: [GSAP, anchors, snap, nested containers]
Cleanup: [destroy/ticker/RAF]
Verification:
[mobile, keyboard, anchors, route changes, modals, FPS]
References
../../references/checklists/lenis-smooth-scroll-checklist.md
../../references/checklists/ui-fidelity-checklist.md
../../references/checklists/engineering-quality-bar.md
1---2name: bosskuai-lenis-smooth-scroll3description: "Use when adding or debugging Lenis smooth scroll: setup, React/Vue/Nuxt, GSAP ticker sync, anchors, nested/modal scroll, snap, horizontal/infinite scroll, cleanup, reduced motion, and whether smooth scroll is warranted."4metadata:5 source: https://skillmd.com/skills/wankimmy/bosskuai-lenis-smooth-scroll6---78# BosskuAI Lenis Smooth Scroll910Use this skill when the task involves Lenis smooth scrolling: installing it, wiring it into a framework, syncing it with GSAP, debugging scroll jank, supporting anchors, handling nested scroll areas, using `lenis/snap`, or reviewing whether smooth scrolling is appropriate.1112## How this differs from nearby skills1314- **`bosskuai-gsap-animation`**: owns GSAP timelines and ScrollTrigger behavior. Load both when Lenis drives scroll and GSAP reacts to it.15- **`bosskuai-ui-ux-design-to-code`**: owns UX and accessibility decisions. Use both when smooth scroll changes navigation, focus, or reduced-motion behavior.16- **`bosskuai-3d-web-development`**: owns WebGL and 3D scroll choreography. Use Lenis here only for the scroll layer.17- **`bosskuai-performance-profiling`**: load when scroll performance is the main defect.18- **GSAP ScrollSmoother** (free with GSAP's no-charge license): an alternative smoother; pick one, never both.1920## Source posture2122This skill was shaped from the upstream [Lenis](https://github.com/darkroomengineering/lenis) package (check `package.json` in your project for the pinned version). Prefer official Lenis docs when exact options or exports matter. The installed version is in the lockfile or `node_modules/lenis/package.json`, and the latest is `npm view lenis version`. Options and exports change between versions, so read the README in `node_modules/lenis/` before you use one.2324## Mindset2526- Smooth scrolling is infrastructure for an experience, not a default upgrade.27- Native scroll semantics, focus behavior, anchors, modals, and nested scroll areas must keep working.28- Use one RAF owner. When GSAP is present, wire Lenis into GSAP ticker instead of running competing loops.29- CSS setup matters. Missing Lenis CSS often creates subtle behavior bugs.30- Touch behavior, iframes, sticky elements, and route transitions deserve extra scrutiny.3132## Workflow3334### Phase 1 - Decide whether Lenis is appropriate35361. Identify the scroll job: general smoothing, scroll-linked animation, WebGL sync, parallax, horizontal, infinite, anchors, snap, or modal/nested scroll support.372. Check accessibility and UX risks: reduced motion, keyboard navigation, focus jumps, anchor links, browser history, and native mobile feel.383. Read existing scroll code before adding Lenis. Do not stack it on top of another smooth-scroll library.3940### Phase 2 - Integrate41424. Install/import from `lenis`; import `lenis/dist/lenis.css` or confirm equivalent CSS is present.435. For simple vanilla use, prefer `autoRaf: true`.446. For GSAP ScrollTrigger or custom animation clocks, set `autoRaf: false`, call `lenis.raf(time)`, and clean up ticker callbacks.457. For React, use `ReactLenis` and `useLenis` from `lenis/react`.468. For Vue, use `VueLenis` and `useLenis` from `lenis/vue`; for Nuxt, configure `modules: ['lenis/nuxt']`.479. For anchors, nested scroll, horizontal, snap, or infinite scroll, configure those intentionally rather than copying a catch-all setup.4849### Phase 3 - Debug and harden505110. Confirm scroll events, progress, direction, velocity, and target scroll behave as expected.5211. Recalculate dimensions when content changes if auto resize is disabled or dynamic layout confuses measurements.5312. Use the `data-lenis-prevent` attribute (or the `prevent` option) for modals and other native-scroll areas; use `allowNestedScroll` only when the performance tradeoff is acceptable.5413. Sync ScrollTrigger with Lenis by updating ScrollTrigger on Lenis scroll and driving Lenis from GSAP ticker.5514. On teardown, call `destroy()` or unmount the provider cleanly, remove ticker callbacks, and stop custom RAF loops. When a modal locks the page, call `lenis.stop()` on open and `lenis.start()` on every close path (button, Escape, route change); a missed `start()` leaves the page frozen.5615. Verify reduced motion, mobile touch, keyboard focus, anchor links, modals, route changes, and back and forward navigation (the restored scroll position should appear without a glide), on the longest real page. Lenis already disables smoothing under `prefers-reduced-motion`; confirm that in the installed version's README rather than re-implementing it.5758## Common patterns5960```js61import Lenis from 'lenis'62import 'lenis/dist/lenis.css'6364const lenis = new Lenis({ autoRaf: true })6566lenis.on('scroll', ({ scroll, progress, velocity }) => {67 // wire only the state you need68})69```7071```js72import Lenis from 'lenis'73import gsap from 'gsap'74import { ScrollTrigger } from 'gsap/ScrollTrigger'7576gsap.registerPlugin(ScrollTrigger)7778const lenis = new Lenis({ autoRaf: false })7980lenis.on('scroll', ScrollTrigger.update)81const tick = (time) => lenis.raf(time * 1000) // named so teardown can remove it82gsap.ticker.add(tick)83gsap.ticker.lagSmoothing(0)84// teardown: gsap.ticker.remove(tick); lenis.destroy()85```8687## Guardrails8889- Do not add Lenis when the page only needs native scroll and a tiny transition.90- Do not break anchors, focus, modals, or nested scroll areas for visual smoothness.91- Do not use multiple independent RAF loops for Lenis plus GSAP.92- Do not enable heavy options like broad nested-scroll detection without checking performance.93- Do not forget cleanup in SPAs, route transitions, and component unmounts.94- Do not test a smooth scroll with a fixed sleep. Wait until the scroll position stops changing.9596## Output format9798```text99Lenis scroll summary:100 Scroll job: [smooth / GSAP sync / horizontal / snap / infinite / nested]101 Runtime: [vanilla / React / Vue / Nuxt]102 RAF owner: [autoRaf / custom RAF / GSAP ticker]103 Accessibility fallback: [reduced motion / native scroll / static]104105Implementation plan:106 Setup: [imports, CSS, provider or instance]107 Options: [only options that matter]108 Integration: [GSAP, anchors, snap, nested containers]109 Cleanup: [destroy/ticker/RAF]110111Verification:112 [mobile, keyboard, anchors, route changes, modals, FPS]113```114115## References116117- `../../references/checklists/lenis-smooth-scroll-checklist.md`118- `../../references/checklists/ui-fidelity-checklist.md`119- `../../references/checklists/engineering-quality-bar.md`