WebberUI

Vortex Background

旋轉漩渦狀波動背景,粒子流線在中心匯聚,適合 CTA 區塊。

以 canvas 2D 粒子流場模擬的漩渦背景:數百條流線沿螺旋向中心收束,疊加有機波動與輝光,游標可擾動附近流線。

載入預覽⋯

Playground

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

420
1
1
2.2
0
<VortexBackground />

安裝

npx shadcn@latest add https://webberui.com/r/vortex-background.json

或在 components.json 設定 registries 後,改用 @webberui/vortex-background 安裝。

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

npm install motion clsx tailwind-merge

使用

import { VortexBackground } from "@/components/ui/vortex-background";

<VortexBackground
  interactive
  className="flex h-[320px] w-full items-center justify-center rounded-xl"
>
  <h3 className="text-3xl font-semibold text-white">走進漩渦中心</h3>
</VortexBackground>

容器高度、置中等佈局直接寫在 className;請避免使用視口高度單位(如 h-screen),改用固定或內容高度讓背景自足有界。

Props

Prop型別預設值說明
particleCountnumber420粒子數量,行動裝置可調低省效能
colorsstring[]品紫→靛→青流線顏色,依序循環套用
speednumber1轉速倍率,越大旋轉越快
spinnumber1漩渦強度,越大向心收束越猛
turbulencenumber2.2波動幅度,疊加在流向上的擾動
particleWidthnumber1.4基準線寬(px)
backgroundColorstring"#070316"拖尾底色,建議用深色突顯輝光
glownumber0光暈模糊量(px),越大越夢幻
interactivebooleanfalse游標擾動附近流線(僅滑鼠生效)
grainbooleanfalse疊加低透明度噪點,減少色帶感
classNamestring透傳容器樣式(佈局、高度、圓角)

可及性

  • 使用者系統開啟「減少動態效果」時,只繪製一幀靜態漩渦、不啟動動畫迴圈與互動
  • 背景層帶 aria-hidden,前景內容照常朗讀
  • 離開元件時 cancelAnimationFrameResizeObserver 皆會清理

On this page