A button that bursts into particles when clicked.
Installation
Usage
import {
IconButton,
IconButtonParticles,
} from '@animate-ui/react/primitives/buttons/icon';
export function Star() {
return (
<IconButton aria-label="Star">
<StarIcon />
<IconButtonParticles className="text-neutral-500" />
</IconButton>
);
}Animation
- Each click bursts particles from the top edge of the button (built on Particles): 6 dots fly 30px out around it (spread evenly at the full 360°), growing then shrinking back to nothing as they fade in and out, over 0.8s with an
easeOut, one after another 50ms apart. A click during a burst starts it over. - 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 press spring.- Under reduced motion, the particles don't burst and the button doesn't scale.
API Reference
IconButton
| 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'> | - |
useIconButton
Returns bursts, the number of clicks so far: each one starts a new burst.
IconButtonParticles
| Prop | Type | Default |
|---|---|---|
size? | number | 4 |
side? | 'top' | 'bottom' | 'left' | 'right' | 'top' |
sideOffset? | number | 0 |
align? | 'start' | 'center' | 'end' | 'center' |
alignOffset? | number | 0 |
count? | number | 6 |
radius? | number | 30 |
spread? | number | 360 |
duration? | number | 0.8 |
holdDelay? | number | 0.05 |
delay? | number | 0 |
...props? | ParticlesEffectProps | - |