A button that bursts into particles when clicked.
Installation
Usage
<script setup lang="ts">
import { IconButton, IconButtonParticles } from '@animate-ui/vue/primitives/buttons/icon';
</script>
<template>
<IconButton aria-label="Star">
<StarIcon />
<IconButtonParticles class="text-neutral-500" />
</IconButton>
</template>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
tap-scale(0.97), on Motion's spring for scale (stiffness: 550, damping: 30). It doesn't scale on hover, unless you sethover-scale. <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 |
|---|---|---|
hover-scale? | number | 1 |
tap-scale? | number | 0.97 |
transition? | Transition | { type: 'spring', stiffness: 550, damping: 30, restSpeed: 10 } |
as-child? | 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' |
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 |
...props? | ParticlesEffectProps | - |