WebberUI

Smooth Follow Cursor

彈簧物理自訂游標,含 blob 變形跟隨。

以彈簧物理驅動的自訂游標:中心點貼手指、外環延遲收斂,並依游標速度沿運動方向拉伸變形,做出「軟身」的跟隨尾巴。

載入預覽⋯

Playground

即時調整 props、程式碼片段同步更新——直接試出你要的樣子再複製。

38
7
0.4
<SmoothFollowCursor />

安裝

npx shadcn@latest add https://webberui.com/r/smooth-follow-cursor.json

或在 components.json 設定 registries 後,改用 @webberui/smooth-follow-cursor 安裝。

安裝依賴後,從 registry JSON(/r/smooth-follow-cursor.jsonfiles[0].content)複製 smooth-follow-cursor.tsx 原始碼到你的 components/ui/ 目錄:

npm install motion clsx tailwind-merge

使用

import { SmoothFollowCursor } from "@/components/ui/smooth-follow-cursor";

<SmoothFollowCursor color="#8b5cf6" blend className="relative h-[340px] w-full">
  {/* 你的內容 */}
</SmoothFollowCursor>;

游標效果只作用在此容器內:容器套用 cursor-none 隱藏原生游標,離開容器即恢復。觸控裝置(pointer: coarse)自動停用並保留原生游標。

Props

Prop型別預設值說明
colorstring"#6366f1"blob 外環顏色
dotColorstring"#6366f1"中心圓點顏色
sizenumber38外環直徑(px)
dotSizenumber7中心圓點直徑(px)
deformbooleantrue是否依速度方向拉伸變形
stretchnumber0.4最大拉伸幅度(01
blendbooleanfalsemix-blend-difference 反相疊色
childrenReactNode容器內容

可及性

  • 使用者系統開啟「減少動態效果」時,停用自訂游標並保留原生游標
  • 觸控裝置自動停用,overflow-hidden 確保變形時的外環不會溢出容器
  • 游標層為純視覺疊層,帶 aria-hiddenpointer-events-none,不影響底層互動

On this page