A visual effect played where the pointer clicks: a ring, a ripple, a crosshair, a burst or particles.
Click anywhere in this area
Installation
Usage
import * as React from 'react';
import { Click } from '@animate-ui/react/primitives/effects/click';
export function Canvas() {
const ref = React.useRef<HTMLDivElement>(null);
return (
<div ref={ref}>
<Click scope={ref} variant="ring">
<p>Click anywhere</p>
</Click>
</div>
);
}Without scope, every click on the page plays the effect.
Animation
- On pointer up, the effect plays centered on the pointer, then is removed. It lasts
duration(400ms by default); withvariant="particles", the dots start one after another and finish a little later. - Effects render in a fixed layer over the page that never catches the pointer, so clicks still reach what's underneath.
- Several clicks in a row each play their own effect.
- Under reduced motion, no effect is played.
API Reference
Click
| Prop | Type | Default |
|---|---|---|
variant? | 'ring' | 'ripple' | 'crosshair' | 'burst' | 'particles' | 'ring' |
color? | string | 'currentColor' |
size? | number | 100 |
duration? | number | 400 |
scope? | React.RefObject<HTMLElement | null> | - |
disabled? | boolean | false |
children? | React.ReactNode | - |
Credits
- Inspired by Framer University.