WebberUI

視差深度卡片

滾動時多層卡片以不同速度位移,形成景深視差。

內建滾動容器,滾動時多層卡片以不同係數位移、縮放與模糊——遠層緩慢且帶景深模糊、近層快速而清晰,形成鏡頭推拉般的視差效果,適合作品展示或功能亮點區塊。

載入預覽⋯

Playground

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

1
320
<ParallaxDepthCards />

安裝

npx shadcn@latest add https://webberui.com/r/parallax-depth-cards.json

或在 components.json 設定 registries 後,改用 @webberui/parallax-depth-cards 安裝。

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

npm install motion clsx tailwind-merge

使用

import { ParallaxDepthCards } from "@/components/ui/parallax-depth-cards";

<ParallaxDepthCards
  height={400}
  intensity={1}
  layers={[
    { icon: "🏔️", title: "遠景", description: "移動最慢、帶景深模糊" },
    { icon: "🌲", title: "中景", description: "以中等速度跟隨滾動" },
    { icon: "✨", title: "近景", description: "移動最快、始終清晰" },
  ]}
/>

Props

Prop型別預設值說明
layersDepthCardLayer[]卡片層資料,索引越大越靠近觀者、視差位移越快
intensitynumber1視差強度(建議 0.4–2),同時影響位移距離與模糊差異
heightnumber420內建滾動容器的高度(px)
classNamestring透傳到最外層滾動容器

DepthCardLayer

欄位型別預設值說明
titlestring卡片標題
descriptionstring卡片說明文字,顯示於標題下方
iconReact.ReactNode卡片左上角的圖示,可傳 emoji 字串或任意 ReactNode
gradientClassNamestring內建配色覆寫卡片背景漸層的 Tailwind class

可及性

  • 使用者系統開啟「減少動態效果」時,卡片以靜態堆疊呈現,不套用滾動位移、縮放與模糊
  • 卡片標題與說明為真實文字節點,輔助科技可正常朗讀;純裝飾的光暈與提示標記為 aria-hidden
  • 滾動容器帶有 role="region"aria-label,並使用 overscroll-contain 避免滾動穿透外層頁面

On this page