YL

BUTTON

涟漪按钮Ripple Button

手指点在哪,一圈水波就从哪扩散开——Material Design 的标志性触觉反馈。

中英对照

中文
涟漪按钮
英文
Ripple Button
别名
波纹按钮、Material Ripple、水波纹
一句话
手指点在哪,一圈水波就从哪扩散开——Material Design 的标志性触觉反馈。

效果预览

拖动参数实时改预览;复制提示词 / CSS 会带上当前数值。

常见变体

描边按钮涟漪Outline Ripple

白底描边按钮上,涟漪改用主题色低透明度,白色涟漪在白底上看不见。

适合用在哪

移动端优先的产品、Material 风格站点、需要强触觉反馈的场景。

不适合:不走 Material 体系的产品(iOS 原生风格、极简品牌站):涟漪是 Material Design 的标志性反馈,混进别的设计语言里像借来的组件;28px 以下的小按钮和表格行内按钮也没有足够面积让水波扩散开。

和相近模式的区别

按压按钮Press Button

不想为点击反馈写 JS、或者界面本身带一点拟物或游戏化风格时,换按压按钮:只用 :active 让整颗按钮下沉 4px,同色厚底说明「按下去了」,不依赖点击坐标;涟漪的优势是能指出点在哪里,更适合面积较大的按钮。

容易踩的坑

  • 动画结束不移除 span 节点,频繁点击后 DOM 中堆积上百个涟漪元素。
  • 涟漪从按钮中心扩散而不是按压点,丢失物理感,看起来像普通闪烁。
  • 浅色描边按钮仍用白色涟漪,几乎不可见,等于没有点击反馈。

设计提示词 · Prompt

涟漪按钮(Ripple Button):点击时在按压坐标插入一个绝对定位的圆形 span(直径设为按钮对角线的 2 倍、背景 rgba(255,255,255,.5)),动画让它的 transform 从 scale(0) 扩到 scale(1)、opacity 从 .9 到 0,600ms ease-out 后移除节点。按钮 overflow:hidden 裁掉溢出。注意涟漪中心必须是按压点而不是按钮中心——这是"物理感"的关键。深色或彩色实心按钮上用白色涟漪;浅色描边按钮上用主题色涟漪。
Ripple Button: on click, insert an absolutely positioned circular span at the press coordinates (diameter set to 2x the button diagonal, background rgba(255,255,255,.5)); animate its transform from scale(0) to scale(1) and opacity from .9 to 0, removing the node after 600ms ease-out. The button uses overflow:hidden to clip the overflow. Note that the ripple center must be the press point, not the button center — this is the key to the "physical feel". Use a white ripple on dark or colored solid buttons; use a theme-color ripple on light outlined buttons.

可复制 CSS

自包含的最小实现,粘贴到空白页面即可生效;类名可以按项目规范改名。

/* <button class="ripple-btn" type="button">点我有一圈涟漪</button>
   JS 在按压点插入 <span class="ripple-btn__wave">,设置 left / top 与 --ripple-size(按钮对角线的 2 倍),animationend 后移除 */
.ripple-btn {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 10px;
  background: #4f46e5;
  color: #fff;
  font: 600 15px/1 system-ui, sans-serif;
  cursor: pointer;
}
.ripple-btn__wave {
  position: absolute;
  z-index: -1;
  width: var(--ripple-size, 300px);
  height: var(--ripple-size, 300px);
  border-radius: 50%;
  background: rgba(255, 255, 255, .5);
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  opacity: .9;
  animation: ripple-wave .6s ease-out forwards;
}
.ripple-btn--outline { background: #fff; color: #4f46e5; box-shadow: inset 0 0 0 1.5px #4f46e5; }
.ripple-btn--outline .ripple-btn__wave { background: rgba(79, 70, 229, .25); }
.ripple-btn:focus-visible { outline: 2px solid #4f46e5; outline-offset: 3px; }
@keyframes ripple-wave {
  to { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}
@keyframes ripple-fade {
  from { opacity: .35; }
  to { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ripple-btn__wave {
    transform: translate(-50%, -50%) scale(1);
    animation-name: ripple-fade;
    animation-duration: .2s;
  }
}

演示 HTML 结构

<div class="s d-rippledemo">
  <button class="d-ripplebtn">点我有一圈涟漪</button>
</div>

无障碍与性能

无障碍

  • 涟漪节点是空的装饰元素,可以加 aria-hidden="true",不影响按钮的可访问名称。
  • prefers-reduced-motion: reduce 时不再扩散,只在整颗按钮上淡出一层 .2s 的浅色,仍保留点击确认。
  • 键盘触发时没有坐标,涟漪从按钮中心出现;同时保留 :focus-visible 焦点环。

性能

  • 只动画 transform 和 opacity;涟漪用 pointer-events: none,animationend 后立即从 DOM 移除。
  • 降级时仍保留一段很短的淡出动画而不是 animation: none,这样 animationend 照常触发,节点会被正常清理。

常见问题

涟漪按钮的英文是什么?

涟漪按钮的英文是 Ripple Button。常见英文别名还包括 Material Ripple。

Ripple Button 的中文是什么?

Ripple Button 的中文是「涟漪按钮」。常见中文别名还包括 波纹按钮、水波纹。手指点在哪,一圈水波就从哪扩散开——Material Design 的标志性触觉反馈。

涟漪效果最少需要哪些 JS?

在按钮上监听 pointerdown:用 getBoundingClientRect() 算出按压点相对按钮的 x、y,以及 Math.hypot(宽, 高) × 2 作为直径;创建 span.ripple-btn__wave,设置 left、top 和 --ripple-size 后插入按钮,监听它的 animationend 再移除。键盘操作不会触发 pointerdown;如果也想给键盘操作显示涟漪,再监听 click,event.detail === 0(键盘触发)时把涟漪放在按钮中心,鼠标和触屏仍只走 pointerdown,避免重复。

涟漪用 pointerdown 还是 click 触发?

pointerdown 在按下瞬间触发,反馈最及时;click 要等松手才触发,涟漪会显得慢半拍。触屏上手指按下后开始滚动页面,浏览器会派发 pointercancel,这时应该让已经出现的涟漪快速淡出,避免滚动时也冒出一圈水波。

常见搭配

同一页面里经常和「涟漪按钮」一起出现的模式,可以收藏后用「组合收藏为整页提示词」一起交给 AI。

所属设计风格

「涟漪按钮」是这些整体设计风格的常见组成部分,在设计风格词典里可以看到整页效果。

标签