A burst of particles around an element, for likes, stars and other celebrations.
Installation
Usage
<script setup lang="ts">
import { Particles, ParticlesEffect } from '@animate-ui/vue/primitives/effects/particles';
defineProps<{ liked: boolean }>();
</script>
<template>
<Particles :animate="liked">
<button>Like</button>
<ParticlesEffect class="size-1 rounded-full bg-red-500" />
</Particles>
</template>The burst plays when animate becomes true. Remount Particles (with a key) to replay it.
Animation
countparticles shoot out from a point on one side of the element, spread overspreaddegrees, then shrink and fade out (800ms, ease-out). Each startshold-delayseconds after the previous one.- Particles are absolutely positioned: the layout never moves.
- With
in-view, the burst waits for the element to be on screen. - Under reduced motion, the burst is skipped: it's decorative.
API Reference
Particles
| Prop | Type | Default |
|---|---|---|
as-child? | boolean | false |
animate? | boolean | true |
#default | slot | - |
in-view? | boolean | false |
in-view-once? | boolean | true |
in-view-margin? | string | '0px' |
...props? | HTMLMotionProps<'div'> | - |
ParticlesEffect
Each particle is rendered with these props: style it with class.
| Prop | Type | Default |
|---|---|---|
side? | 'top' | 'bottom' | 'left' | 'right' | 'top' |
side-offset? | number | 0 |
align? | 'start' | 'center' | 'end' | 'center' |
align-offset? | number | 0 |
count? | number | 6 |
radius? | number | 30 |
spread? | number | 360 |
duration? | number | 0.8 |
hold-delay? | number | 0.05 |
delay? | number | 0 |
transition? | Transition | - |
...props? | HTMLMotionProps<'div'> | - |
Credits
- Inspired by SHSF UI.