圆柱轮播

New

轮播项排列在圆柱体内壁,越靠中心越远、越靠边缘越大。可拖拽、滚动或方向键滚动切换,带弹性滑动与吸附。「减少动效」偏好下取消滑动过渡。

Drag, scroll or use arrow keys to roll

安装

用 shadcn CLI 添加,或手动复制源码。

$ bunx --bun shadcn add @uilab/cylinder-carousel

API 参考

itemSize?
number

Max item box size in px (square) at full size, i.e. at the container edge. Balls shrink below this automatically so the row keeps breathing room in narrow containers.

200
visibleItems?
number

How many item slots span the container width.

5
variant?
"concave" | "convex"

"concave" (default): inside of the cylinder — center ball smallest and dipped, growing toward the edges. "convex": outside of the cylinder — center ball biggest and raised, shrinking toward the edges.

concave
minScale?
number

Scale of the smallest ball (center for concave, edges for convex); the biggest reaches 1.

0.55
dragSpeed?
number

Items rolled per item-width dragged — above 1 the wall outruns the pointer, which reads as a lighter, freer roll.

1.5
arc?
number

Curve depth in px: for concave, how far the edge balls ride above the center one (valley); for convex, how far below (arch). 0 = flat line. Defaults to 35% of the item size.

snap?
boolean

Snap to the nearest item when the roll settles.

true
autoRotate?
boolean

Roll on its own until interacted with.

false
autoRotateSpeed?
number

Auto-roll speed in items per second.

0.4
defaultIndex?
number
0
onIndexChange?
((index: number) => void)
height?
number

Stage height in px. Defaults to `itemSize`.

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.