snapVanish(element, options?) returns a Promise that settles when the effect finishes. Dust colors come from getComputedStyle on the node and its descendants (no html2canvas or raster snapshots). A good fit for delete actions and dismissible cards.
One click runs the disintegration, then the node is removed from the DOM.
ID #snap-demo — this block dissolves into canvas particles tinted from this element’s computed CSS (background, text, border, and visible child paints).
npm install snap-vanish
yarn add snap-vanish
pnpm add snap-vanish
Returns a Promise<void>.
Colors. There is no public sampleColors (or similar) helper. The package reads computed styles inside snapVanish and builds a palette from the target’s backgroundColor, color, borderColor, plus non-transparent paints on descendants.
| Option | Type | Default | Description |
|---|---|---|---|
| duration | number | 1500 | Animation length in ms |
| particles | number | 30 | Particle count |
| removeElement | boolean | true | Remove node on completion (otherwise hide) |
| onComplete | () => void | — | Sync callback after finish |
| seed | number | — | Optional PRNG seed for tests |