WebberUI

液體填充按鈕

hover 時液面自底部帶波浪漲滿按鈕,文字反色。

hover 或鍵盤聚焦時,液體自按鈕底部以彈簧節奏漲滿:SVG 波浪頂緣雙層流動、氣泡上升,文字以 clip-path 與液面同步反色,適合作為醒目的 CTA 按鈕。

載入預覽⋯

Playground

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

0.14
10
2.2
<LiquidFillButton />

安裝

npx shadcn@latest add https://webberui.com/r/liquid-fill-button.json

或在 components.json 設定 registries 後,改用 @webberui/liquid-fill-button 安裝。

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

npm install motion clsx tailwind-merge

使用

import { LiquidFillButton } from "@/components/ui/liquid-fill-button";

<LiquidFillButton color="#4f46e5" onClick={() => console.log("clicked")}>
  立即開始
</LiquidFillButton>

Props

Prop型別預設值說明
childrenReact.ReactNode按鈕內容(文字與圖示),會同步渲染一份反色層
colorstring"#6366f1"液體顏色(任何合法 CSS 顏色值)
fillTextColorstring"#ffffff"液體覆蓋後的文字顏色
idleLevelnumber0.14靜止時的液面高度(0~1)
waveHeightnumber10波浪振幅(px),數值越大波峰越高
waveDurationnumber2.2前景波浪流動一輪的秒數,背景波自動放慢並反向
classNamestring透傳合併到按鈕根元素
...propsButtonHTMLAttributes其餘原生 <button> 屬性(onClickdisabled 等)

可及性

  • 使用者系統開啟「減少動態效果」時,液面直接切換高度、不彈跳,波浪與氣泡停止流動
  • 反色文字層與液體層皆為 aria-hiddenpointer-events-none,輔助科技只會朗讀一次按鈕內容
  • 鍵盤 Tab 聚焦同樣觸發填充,並保留 focus-visible ring 作為焦點指示
  • 根元素為原生 <button type="button">,完整支援 disabled、表單語意與所有原生屬性

On this page