0
Documentation

Ripple

Zero-dependency tactile press ripple and hover state layer powered by the Web Animations API.

A lightweight Client Component that renders a radial press ripple and hover state layer inside any interactive parent element using the Web Animations API. Used across Button, Accordion, Card, Command, Drawer, and Sidebar.

Installation

How It Works

  • Parent-attached listeners: Ripple listens directly on its parentElement for pointer and keyboard (Enter, Space) events—no wrapper element required. If the parent has position: static, Ripple upgrades it to relative and clips via border-radius: inherit and overflow: hidden.
  • Origin-aware expansion: Pointer presses originate at the click coordinates and travel smoothly toward the center of the element, scaling across its full diagonal (Math.hypot). Keyboard activations originate from the center.
  • Minimum press hold: Releases wait until minimumPressDuration (225ms by default) has elapsed before fading out, preventing quick taps from flashing abruptly.
  • Touch & disabled awareness: Touch pointers skip the hover layer (pointerType !== "touch"), disabled controls (disabled, aria-disabled="true", data-disabled) ignore presses, and prefers-reduced-motion: reduce collapses the growth duration to 0ms.

Usage

Basic

Place <Ripple /> as a child inside any interactive trigger (button, a, or custom clickable container):

Press-Only Ripple (Without Hover Overlay)

For items that already apply their own hover background (such as menu or drawer items), set hoverOpacity={0}:

Custom Color and Intensity

By default Ripple uses currentColor, matching the parent text color. You can override color, opacity, and duration:

API

RippleProps

Extends React.HTMLAttributes<HTMLSpanElement>.

PropTypeDefaultDescription
colorstring"currentColor"CSS color used for both the radial ripple and hover overlay.
durationnumber450Ripple expansion duration in milliseconds.
opacitynumber0.1Peak opacity of the active press ripple.
hoverOpacitynumber0.08Opacity of the hover state layer (0 disables hover tint).
hoverDurationnumber150Fade duration in milliseconds for the hover state layer.
minimumPressDurationnumber225Minimum milliseconds the ripple stays visible before fading out on release.
disabledbooleanfalseDisables pointer/keyboard listeners and hides the hover state layer.

© taut ui — built with Base UI and Tailwind CSS v4.