Smooth Scroll
Eases scrolling for a page or a scroll container.
Installation
pnpm dlx shadcn@latest add @paneui/smooth-scrollUsage
Examples
Scrollbars
Contained mode scrolls in a Scroll Area: thin overlay bars inside the frame that follow the eased position. container points at its viewport.
Motion
Under reduced motion nothing is eased, so scrolling is native and scrollTo jumps instead of animating. Touch scrolling stays native unless you set touch.
Related
Scroll Progress, Scroll To and Scroll Reveal read this provider.
SmoothScroll
Eased scroll container (or, with root, a provider that eases the window). Also accepts every prop of div.
- root= false
- boolean
trueeases the whole page and renders only the provider.falserenders its own scroll container; give it a height.- lerp= 0.1
- number
- Smoothing per frame, 0–1. Lower is heavier. Ignored when
durationis set. - duration
- number
- Fixed ease duration in seconds for wheel and programmatic scrolls.
- orientation= "vertical"
- "vertical" | "horizontal"
- Scroll axis.
- wheelMultiplier= 1
- number
- Multiplies wheel deltas.
- touch= false
- boolean
- Ease touch scrolling too. Off by default so phones keep native momentum.
- contentClassName
- string
- Class for the inner content element (contained mode only).
| Prop | Type | Default | Description |
|---|---|---|---|
| root | boolean | false | true eases the whole page and renders only the provider. false renders its own scroll container; give it a height. |
| lerp | number | 0.1 | Smoothing per frame, 0–1. Lower is heavier. Ignored when duration is set. |
| duration | number | — | Fixed ease duration in seconds for wheel and programmatic scrolls. |
| orientation | "vertical" | "horizontal" | "vertical" | Scroll axis. |
| wheelMultiplier | number | 1 | Multiplies wheel deltas. |
| touch | boolean | false | Ease touch scrolling too. Off by default so phones keep native momentum. |
| contentClassName | string | — | Class for the inner content element (contained mode only). |
- data-smooth
- Present on the container while it is eased.
| Data attribute | Description |
|---|---|
| data-smooth | Present on the container while it is eased. |
useSmoothScroll
Scroll state for the nearest SmoothScroll. Outside a provider it falls back to the window's native scroll.
- lenis
- Lenis | null
- The easing instance, or
nullon the native or reduced-motion path. - smooth
- boolean
- Whether scrolling is currently eased.
- container
- RefObject<HTMLElement | null> | null
- The scroll container, or
nullfor the window. - offset
- MotionValue<number>
- Current scroll offset in px.
- progress
- MotionValue<number>
- Scroll position from 0 (start) to 1 (end).
- velocity
- MotionValue<number>
- Signed scroll velocity in px per frame.
- scrollTo
- (target: number | string | HTMLElement, options?: { offset?: number; duration?: number; immediate?: boolean }) => void
- Scroll to a px offset, selector or element. Jumps under reduced motion.
| Prop | Type | Default | Description |
|---|---|---|---|
| lenis | Lenis | null | — | The easing instance, or null on the native or reduced-motion path. |
| smooth | boolean | — | Whether scrolling is currently eased. |
| container | RefObject<HTMLElement | null> | null | — | The scroll container, or null for the window. |
| offset | MotionValue<number> | — | Current scroll offset in px. |
| progress | MotionValue<number> | — | Scroll position from 0 (start) to 1 (end). |
| velocity | MotionValue<number> | — | Signed scroll velocity in px per frame. |
| scrollTo | (target: number | string | HTMLElement, options?: { offset?: number; duration?: number; immediate?: boolean }) => void | — | Scroll to a px offset, selector or element. Jumps under reduced motion. |