A button that sends a ripple out from where it is clicked.
Installation
Usage
import {
RippleButton,
RippleButtonRipples,
} from '@animate-ui/react/primitives/buttons/ripple';
export function Send() {
return (
<RippleButton className="[--ripple-button-ripple-color:white]">
Send
<RippleButtonRipples />
</RippleButton>
);
}Animation
- Each click sends a ripple from the pointer: it grows to
scalewhile fading out over 0.6s, then is removed. Rapid clicks each get their own ripple. - Pressing scales the button to
tapScale(0.97), on Motion's spring for scale (stiffness: 550, damping: 30). It doesn't scale on hover, unless you sethoverScale. <AnimateUIProvider tempo>paces the default spring and ripple.- Under reduced motion, the ripple fades in place without growing, and the button doesn't scale.
API Reference
RippleButton
| Prop | Type | Default |
|---|---|---|
hoverScale? | number | 1 |
tapScale? | number | 0.97 |
transition? | Transition | { type: 'spring', stiffness: 550, damping: 30, restSpeed: 10 } |
asChild? | boolean | false |
...props? | HTMLMotionProps<'button'> | - |
RippleButtonRipples
| Prop | Type | Default |
|---|---|---|
color? | string | 'var(--ripple-button-ripple-color)' |
scale? | number | 10 |
transition? | Transition | { duration: 0.6, ease: 'easeOut' } |
asChild? | boolean | false |
...props? | HTMLMotionProps<'span'> | - |
CSS variables
| Prop | Type | Default |
|---|---|---|
--ripple-button-ripple-color? | color | - |