WebberUI

Text Hover Gradient

hover 時以漸層輪廓描邊填色(x.ai 風),聚光跟隨游標顯露色彩。

以 SVG 描邊呈現文字,掛載時自動描一次輪廓;hover 時漸層聚光跟隨游標,將描邊逐步填上光譜色。

載入預覽⋯

Playground

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

56
0.75
0.28
3.5
<TextHoverGradient />

安裝

npx shadcn@latest add https://webberui.com/r/text-hover-gradient.json

或在 components.json 設定 registries 後,改用 @webberui/text-hover-gradient 安裝。

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

npm install motion clsx tailwind-merge

使用

import { TextHoverGradient } from "@/components/ui/text-hover-gradient";

<TextHoverGradient text="webber" className="text-6xl font-bold" />

Props

Prop型別預設值說明
textstring要描邊填色的文字(單行)
colorsstring[]暖冷交錯光譜漸層停靠色,沿水平方向鋪開
strokeWidthnumber0.75描邊粗細(相對 viewBox 高 100 的 user unit)
drawDurationnumber3.5掛載自描輪廓時長(秒),設 0 關閉
followDurationnumber0.28聚光跟隨游標的收斂時長(秒)
spotlightstring"22%"聚光半徑(viewBox 百分比字串)
fontSizenumber56字級(SVG user unit),文字置中於 300x100viewBox

可及性

  • 使用者系統開啟「減少動態效果」時,跳過自描輪廓與聚光動畫,直接顯示完整漸層描邊
  • viewBox 縮放,字級與描邊隨容器等比適配

On this page