A button that emits a ripple from the exact point clicked.
Installation
Install the packages
npm install @prequelui/react motion@prequelui/react reuses the primitive library your components already depend on.
Add the component
npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/ripple-button.jsonnpx shadcn@latest add https://animate.prequelui.terravidhal.me/r/ripple-button.json
Turn on the motion
npx @prequelui/cli@latest animate ripple-buttonThe CLI finds the component through components.json, swaps the import and removes the CSS animation classes that Motion replaces.
Usage
Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.
import { RippleButton, RippleButtonRipples } from "@/components/prequelui/ripple-button";
export default function Demo() {
return (
<RippleButton>
Click anywhere
<RippleButtonRipples />
</RippleButton>
);
}import { RippleButton } from "@/components/prequelui/ripple-button";
export function Variant() {
return (
<RippleButton tempo={1.2}>
…
</RippleButton>
);
}Animation
Each click starts a circle at the exact point of the pointer inside the button. The circle expands to ten times its size while fading from half opacity to nothing, so the wave leaves the surface clean.
- Ripple: 600 ms ease-out, scale 0 → 10, opacity 0.5 → 0.
- The origin is corrected for any CSS scaling of the button.
- Ripples are removed after their tempo-scaled duration.
- Reduced motion renders the ripple at full size with only the fade.
API Reference
Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.