Smooth Scroll

@sushindustries/ui

Mounts Lenis for the page and renders nothing. Respects reduced motion.

4 min read
View as MarkdownEdit on GitHub

SmoothScroll mounts Lenis for the whole document and renders nothing itself - what changes is how the page feels under the wheel, easing instead of jumping frame to frame. Mount it once near the root; anyone with reduced motion set gets the browser's own scroll instead, which is correct for them.

Viewport width
Phone22remthe floor, the narrowest this promises to work at
tanstacktanstack add https://adamjurek.com/r/tanstack/smooth-scroll.jsonshadcnpnpm dlx shadcn@latest add https://adamjurek.com/r/shadcn/smooth-scroll.json

Why it is built this way

It mounts inside an effect rather than at module scope, because Lenis touches window and document immediately, and the root component that renders it also renders on the server. Effects only run in the browser, so the server render and the first client render both stay untouched, and Lenis only takes over once there is an actual document for it to take over.

Install

tanstack add https://adamjurek.com/r/tanstack/smooth-scroll.json
shell
pnpm dlx shadcn@latest add https://adamjurek.com/r/shadcn/smooth-scroll.json
shell
pnpm add @sushindustries/ui @sushindustries/atoms
shell

What you get

Version0.1.0
Categorymotion · Scroll effects
Filessmooth-scroll.tsx
Dependencieslenis@1.3.26
Tagsscroll, lenis