滚动动效

由滚动驱动的动效:基于 Lenis 的平滑滚动 Provider,以及读取其状态的阅读进度指示器。

平滑滚动

smooth-scroll.tsx

基于 Lenis 的平滑滚动 Provider,提供 useSmoothScroll hook 暴露滚动偏移、进度与速度。对「减少动效」偏好友好。

Section 1
Section 2
Section 3
Section 4
Section 5
Section 6
Section 7
Section 8
Section 9
Section 10
Section 11
Section 12
Section 13
Section 14
Section 15
Section 16

安装

$ bunx --bun shadcn add @uilab/smooth-scroll

API 参考

root?
boolean

Drive the page (window) when true, or a contained scroll area when false.

true
lerp?
number

Smoothing factor; lower is smoother and heavier.

0.1
duration?
number

Wheel / programmatic ease duration in seconds.

1.2
orientation?
"horizontal" | "vertical"
vertical
wheelMultiplier?
number

Wheel scroll speed multiplier.

1
touch?
boolean

Smooth touch scrolling. Off by default — native momentum is good on mobile.

false
className?
string

滚动进度条

scroll-progress.tsx

阅读进度指示器——固定条形或环形样式——通过 useSmoothScroll 读取滚动位置驱动,并带弹簧平滑处理。

Section 1
Section 2
Section 3
Section 4
Section 5
Section 6
Section 7
Section 8
Section 9
Section 10
Section 11
Section 12
Section 13
Section 14
Section 15
Section 16
Section 17
Section 18

安装

$ bunx --bun shadcn add @uilab/scroll-progress

API 参考

variant?
"circle" | "bar"
position?
"bottom" | "top"
height?
number

Bar thickness in px.

fixed?
boolean

Position the bar with `fixed` (page) or `absolute` (embedded).

progress?
MotionValue<number>

Override the scroll source. Defaults to the page via useSmoothScroll.

spring?
boolean

Spring-smooth the value. Disabled automatically under reduced motion.

className?
string
size?
number

Diameter in px.

thickness?
number

Stroke width in px.

视差滚动

parallax.tsx

包裹组件,子元素随进入视口的过程按设定速度因子偏移,支持任意轴向。对「减少动效」偏好友好。

Scroll down ↓
Parallax
↑ Scroll up

安装

$ bunx --bun shadcn add @uilab/parallax

API 参考

speed?
number

Drift as a fraction of the element's travel through the viewport. Positive moves with the scroll (foreground), negative against it (background). ~0.1–0.5 reads best.

0.3
axis?
"x" | "y"
y
container?
RefObject<HTMLElement | null>

Scroll container for contained scroll areas. Defaults to the viewport.

spring?
boolean

Spring-smooth the drift. Disabled automatically under reduced motion.

true
className?
string

滚动至指定位置

scroll-to.tsx

点击后通过当前 SmoothScroll Provider 平滑滚动到目标位置(偏移量、选择器或元素);「减少动效」偏好下直接跳转。

Intro
Features
Pricing
FAQ

安装

$ bunx --bun shadcn add @uilab/scroll-to

API 参考

to
ScrollTarget

Where to scroll: px offset, selector string or element.

offset?
number

Extra px offset from the target (e.g. to clear a sticky header).

duration?
number

Override the ease duration in seconds.

className?
string

滚动揭示

scroll-reveal.tsx

子元素进入视口时以弹簧滑动加模糊效果揭示,可设置只触发一次或每次都触发。「减少动效」偏好下保留淡入效果。

Scroll ↓
Spring slide
Blur in
Staggered by delay
Reveal once
End

安装

$ bunx --bun shadcn add @uilab/scroll-reveal

API 参考

y?
number

Slide distance in px before reveal.

16
blur?
number

Enter blur in px (kept ≤ 10 per motion conventions).

8
duration?
number

Reveal duration in seconds.

0.6
delay?
number
0
once?
boolean

Reveal only once (default) or every time it enters view.

true
amount?
number | "all" | "some"

Portion of the element that must be visible to trigger.

0.3
root?
RefObject<Element | null>

Scroll root for contained scroll areas. Defaults to the viewport.

className?
string

Keep in mind

Some components on this site are inspired by or recreated from existing work across the web. I'm not here to take credit; just to learn, experiment, and sometimes push things a bit further. If something looks familiar and I forgot to mention you, reach out and I'll fix that right away.