Particle Effects for Buttons

Today we’d like to share a little effect library with you that can be used to create bursting particle effects. The idea is to desintegrate an element into particles and making it disappear (and vice versa). This effect looks really interesting on buttons, so we’ve created a little collection that showcases a bunch of different styles for the effect.

The inspiration for this idea came from Cuberto’s Hyperloop interface shot, Route Selection UI.

The demo is kindly sponsored by Segment: One API, 200+ tools, no more integrations.
If you would like to sponsor one of our demos, find out more here.

The animations are powered by anime.js. Here’s an example of how you can use it:

<!-- Normal HTML element to disintegrate -->
  <button class="button">Button</button>
  <script src="anime.min.js"></script>
  <script src="dist/particles.min.js"></script>
      // Initialize a new instance of Particles to disintegrate/integrate the button
      var particles = new Particles('.button');
      // Disintegrate the button into particles
      // particles.integrate(); // would do the opposite

The following options are available:

canvasPadding Integer 150Padding for the generated canvas that will be positioned right behind the target element. A canvasPadding = 0 will cause the canvas and the target element to have the same dimensions.
duration Integer 1000Duration (ms) to perform the animations of target element and particles.
easing String or Function easeInOutCubicEasing function to perform the animation of target element. It will be passed directly to anime.js.
type String circleType of particle. Could be any of the following values: circle, rectangle, triangle
style String fillStyle of particle. Could be any of the following values: fill, stroke.
direction String leftDirection to start disintegrating the element. Could be any of the following values: left, right top, bottom. The opposite direction will be used to perform the integrate operation.
size Float or FunctionRandom from 1 to 4Size (px) for particles.
speed Float or FunctionRandom from -2 to 2Pixels per frame that a particle will be moved. It could be a function to set it randomly per particle (as default value).
color StringTarget’s background-colorColor used to fill the particles.
Float 3A coefficient to calculate the amount of particles to animate. A particlesAmountCoefficient = 0 will result in 0 particles, while bigger values will increase the amount of particles.
Float 20A coefficient to calculate the oscilation of particles while animating. A oscilationCoefficient = 0 will result in no oscilation (straight movements), while bigger values will increase the oscilation, resulting in
a kind of randomness.
begin Function undefinedExecute a function at the beginning of the animation.
complete Function undefinedExecute a function at the end of the animation.

We hope you enjoy this and find it useful!

References and Credits

Particle Effects for Buttons was written by Luis Manuel and published on Codrops.