Skip to content

Ripple button

Click-origin pastel ripple with cursor-mapped colour and spring physics. Every tap is uniquely tinted by where the pointer lives in the viewport.

  • Spring Physics
  • requestAnimationFrame
  • cursorColour

cursor position tints each ripple

Display settings

Dark mode
Reduce motion

Usage

Drop it in

import
import { RippleButton } from "@/app/lib/components/ripple-button";
example 1
<RippleButton onClick={handleSave}>Save changes</RippleButton>
<RippleButton rippleDuration={800} rippleScale={3.2}>Confirm</RippleButton>
<RippleButton usePointerColour={false} glowOnHover={false}>Static</RippleButton>

API

Props

PropTypeDefault
children*

Button label or any renderable content.

ReactNode—
rippleDuration

Time in ms for the ripple to fully decay to zero opacity. Default: 650

number650
rippleScale

Final scale multiplier of the ripple circle relative to button dimensions. Should exceed 2 to flood-fill the button. Default: 2.8

number2.8
usePointerColour

Maps ripple colour to cursor viewport position and time via pastelColour(). Set false for a fixed neutral pastel. Default: true

booleantrue
glowOnHover

Enables the live cursor-reactive pastel box-shadow glow on hover. Default: true

booleantrue

Read from the component's source at build time. * required.

Accessibility

Works with

Cursor
Reacts to where the pointer is, not just whether it's over the element.
Touch
Follows your finger while it's down, then settles a moment after you lift.
Keyboard
Focus lights it up the way the cursor does. Every action has a key.
Reduced motion
Nothing moves or springs. Colour still answers, without drifting.