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 { RippleButton } from "@/app/lib/components/ripple-button";<RippleButton onClick={handleSave}>Save changes</RippleButton>
<RippleButton rippleDuration={800} rippleScale={3.2}>Confirm</RippleButton>
<RippleButton usePointerColour={false} glowOnHover={false}>Static</RippleButton>API
Props
| Prop | Type | Default |
|---|---|---|
children*Button label or any renderable content. | ReactNode | — |
rippleDurationTime in ms for the ripple to fully decay to zero opacity. Default: 650 | number | 650 |
rippleScaleFinal scale multiplier of the ripple circle relative to button dimensions. Should exceed 2 to flood-fill the button. Default: 2.8 | number | 2.8 |
usePointerColourMaps ripple colour to cursor viewport position and time via pastelColour(). Set false for a fixed neutral pastel. Default: true | boolean | true |
glowOnHoverEnables the live cursor-reactive pastel box-shadow glow on hover. Default: true | boolean | true |
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.