MCPcopy
hub / github.com/darkroomengineering/lenis

github.com/darkroomengineering/lenis @v1.3.25 sqlite

repository ↗ · DeepWiki ↗ · release v1.3.25 ↗
124 symbols 255 edges 45 files 30 documented · 24%
README

LENIS

npm downloads size

Introduction

Lenis ("smooth" in latin) is a lightweight, robust, and performant smooth scroll library. It's designed by @darkroom.engineering to be simple to use and easy to integrate into your projects. It's built with performance in mind and is optimized for modern browsers. It's perfect for creating smooth scrolling experiences on your website such as WebGL scroll syncing, parallax effects, and much more, see Demo and Showcase.

Read our Manifesto to learn more about the inspiration behind Lenis.

Features

  • Lightweight & dependency-free — the whole library is a few KB with zero runtime dependencies
  • Runs on native scroll — wraps the browser's own scroll, so position: sticky, anchor links, and accessibility keep working
  • Any axis — smooth vertical, horizontal, and nested scrolling from a single instance
  • Built for sync — drives WebGL scroll scenes, GSAP ScrollTrigger, and parallax off one loop
  • Framework adapters — first-class packages for React, Vue, and Framer
  • Scroll snapping — the snap plugin aligns sections without fighting the smooth scroll

Sponsors

If you’ve used Lenis and it made your site feel just a little more alive, consider sponsoring.

Your support helps us smooth out the internet one library at a time—and lets us keep building tools that care about the details most folks overlook.

Glauber Scott Luis Bizarro cachet.studio Julian Fella OHO Design OFF+BRAND. Jose J. Mendez Rodriguez Velox Themes

Packages

Installation

Using a package manager:

npm i lenis
# or
yarn add lenis
# or
pnpm add lenis
import Lenis from 'lenis'

Using scripts:

<script src="https://unpkg.com/lenis@1.3.25/dist/lenis.min.js"></script> 

Setup

Basic:

// Initialize Lenis
const lenis = new Lenis({
  autoRaf: true,
});

// Listen for the scroll event and log the event data
lenis.on('scroll', (e) => {
  console.log(e);
});

Custom raf loop:

// Initialize Lenis
const lenis = new Lenis();

// Use requestAnimationFrame to continuously update the scroll
function raf(time) {
  lenis.raf(time);
  requestAnimationFrame(raf);
}

requestAnimationFrame(raf);

Recommended CSS:

Import stylesheet:

import 'lenis/dist/lenis.css'

Or link the CSS file:

<link rel="stylesheet" href="https://unpkg.com/lenis@1.3.25/dist/lenis.css">

Or add it manually:

See lenis.css stylesheet

GSAP ScrollTrigger:

// Initialize a new Lenis instance for smooth scrolling
const lenis = new Lenis();

// Synchronize Lenis scrolling with GSAP's ScrollTrigger plugin
lenis.on('scroll', ScrollTrigger.update);

// Add Lenis's requestAnimationFrame (raf) method to GSAP's ticker
// This ensures Lenis's smooth scroll animation updates on each GSAP tick
gsap.ticker.add((time) => {
  lenis.raf(time * 1000); // Convert time from seconds to milliseconds
});

// Disable lag smoothing in GSAP to prevent any delay in scroll animations
gsap.ticker.lagSmoothing(0);

No-code usage

One line, no build step — just drop this into your HTML:

<link rel="stylesheet" href="https://unpkg.com/lenis@1.3.25/dist/lenis.css">
<script src="https://unpkg.com/lenis@1.3.25/dist/lenis.min.js"></script> 
<script>new Lenis({ autoRaf: true, autoToggle: true, anchors: true, allowNestedScroll: true, naiveDimensions: true, stopInertiaOnNavigate: true })</script>

That's it, your page now has smooth scrolling and should handle most of the usual issues such as: - compatibility with other packages - modals - smooth anchors - scroll reset on page change

Settings

Option Type Default Description
allowNestedScroll boolean false Automatically allow nested scrollable elements to scroll natively. This is the simplest way to handle nested scroll. ⚠️ Can create performance issues since it checks the DOM tree on every scroll event. If that's a concern, use prevent option instead.
anchors boolean, ScrollToOptions false Scroll to anchor links when clicked. If true is passed, it will enable anchor links with default options. If ScrollToOptions is passed, it will enable anchor links with the given options.
autoRaf boolean false Whether or not to automatically run requestAnimationFrame loop.
autoResize boolean true Resize instance automatically based on ResizeObserver. If false you must resize manually using .resize().
autoToggle boolean false Automatically start or stop the lenis instance based on the wrapper's overflow property, ⚠️ this requires Lenis recommended CSS. Safari > 17.3, Chrome > 116 and Firefox > 128 (https://caniuse.com/?search=transition-behavior).
content HTMLElement document.documentElement The element that contains the content that will be scrolled, usually wrapper's direct child.
duration number 1.2 The duration of scroll animation (in seconds). Useless if lerp defined.
easing function (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)) The easing function to use for the scroll animation, our default is custom but you can pick one from Easings.net. Useless if lerp defined.
eventsTarget HTMLElement, Window wrapper The element that will listen to wheel and touch events.
gestureOrientation string vertical The orientation of the gestures. Can be vertical, horizontal or both.
infinite boolean false Enable infinite scrolling! syncTouch: true is required on touch devices (See example).
lerp number 0.1 Linear interpolation (lerp) intensity (between 0 and 1).
naiveDimensions boolean false If true, Lenis will use naive dimensions calculation. ⚠️ Be careful, this has a performance impact.
orientation string vertical The orientation of the scrolling. Can be vertical or horizontal.
overscroll boolean true Similar to CSS overscroll-behavior (https://developer.mozilla.org/en-US/docs/Web/CSS/overscroll-behavior).
prevent function undefined Manually prevent scroll to be smoothed based on elements traversed by events. If true is returned, it will prevent the scroll to be smoothed. Example: (node) => node.classList.contains('cookie-modal').
smoothWheel boolean true Smooth the scroll initiated by wheel events.

Extension points exported contracts — how you extend this code

Window (Interface)
(no doc)
packages/core/src/types.ts
Plugin (Interface)
(no doc)
packages/vue/nuxt/types/app.d.ts
Window (Interface)
(no doc)
playground/core/test.ts
Window (Interface)
(no doc)
playground/snap/test.ts
GlobalComponents (Interface)
(no doc)
packages/vue/src/provider.ts

Core symbols most depended-on inside this repo

emit
called by 13
packages/core/src/lenis.ts
on
called by 9
packages/core/src/lenis.ts
scrollTo
called by 8
packages/core/src/lenis.ts
reset
called by 7
packages/core/src/lenis.ts
iife
called by 4
tsdown.config.ts
set
called by 4
packages/react/src/store.ts
updateClassName
called by 4
packages/core/src/lenis.ts
setRect
called by 3
packages/snap/src/element.ts

Shape

Method 63
Function 40
Class 16
Interface 5

Languages

TypeScript100%

Modules by API surface

packages/core/src/lenis.ts34 symbols
packages/snap/src/snap.ts14 symbols
packages/snap/src/element.ts11 symbols
packages/react/src/store.ts7 symbols
packages/vue/src/provider.ts6 symbols
packages/core/src/virtual-scroll.ts6 symbols
packages/core/src/emitter.ts6 symbols
packages/core/src/maths.ts5 symbols
packages/core/src/dimensions.ts5 symbols
packages/core/src/animate.ts5 symbols
playground/infinite/test.ts3 symbols
playground/touch-debug/test.ts2 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

@astrojs/check0.9.4 · 1×
@astrojs/react4.1.6 · 1×
@astrojs/vue5.0.6 · 1×
@biomejs/biome2.4.2 · 1×
@types/react19.0.7 · 1×
@types/react-dom19.0.3 · 1×
astro5.1.8 · 1×
gsaplatest · 1×
lenis* · 1×
lorem-ipsum2.0.8 · 1×
nuxt3.15.3 · 1×
react19.0.0 · 1×

For agents

$ claude mcp add lenis \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact