Layout

Collision

Collision detection system with animated beams and explosion effects.

The Collision component system creates animated beams that travel across the screen and explode when they collide with a target element. It features realistic physics-based animations, customizable colors, and smooth transitions.

Usage

Target Area

Beams will collide here

<template>
  <MCollisionBackgroundBeams class="h-64 w-full rounded-lg overflow-hidden">
    <div class="relative z-10 flex items-center justify-center h-full">
      <div class="bg-default p-6 rounded-lg shadow-lg text-center">
        <h3 class="font-bold text-lg mb-2">
          Target Area
        </h3>
        <p class="text-muted">
          Beams will collide here
        </p>
      </div>
    </div>
  </MCollisionBackgroundBeams>
</template>

Examples

Custom Beam Configuration

Custom Timing

Beams with custom timing and rotation

<template>
  <MCollisionBackgroundBeams
    :beams="[
      {
        initialX: 150,
        translateX: 150,
        duration: 3,
        delay: 1,
        repeatDelay: 2,
      },
      {
        initialX: 400,
        translateX: 400,
        duration: 6,
        delay: 2,
        repeatDelay: 4,
        className: 'h-8',
      },
      {
        initialX: 650,
        translateX: 650,
        duration: 4,
        delay: 0,
        repeatDelay: 3,
        rotate: 15,
      },
    ]"
    class="h-64 w-full rounded-lg overflow-hidden"
  >
    <div class="relative z-10 flex items-center justify-center h-full">
      <div class="bg-default p-6 rounded-lg shadow-lg text-center">
        <h3 class="font-bold text-lg mb-2">
          Custom Timing
        </h3>
        <p class="text-muted">
          Beams with custom timing and rotation
        </p>
      </div>
    </div>
  </MCollisionBackgroundBeams>
</template>

Customize

Build in motion

Layered effects stay out of the way until you need them

Customize

Beams

Props

MCollisionBackgroundBeams Props

Prop Type Default Description
classstring''CSS classes to apply to the container.
beamsBeamOptions[]7 beams with default settingsArray of beam configuration objects.

BeamOptions

Prop Type Default Description
initialXnumber-Initial X position of the beam.
translateXnumber-X translation distance for the beam animation.
initialYnumber-Initial Y position of the beam.
translateYnumber-Y translation distance for the beam animation.
rotatenumber-Rotation angle of the beam in degrees.
classNamestring-Additional CSS classes to apply to the beam.
durationnumber-Duration of the beam animation in seconds.
delaynumber-Delay before starting the beam animation in seconds.
repeatDelaynumber-Delay between animation repeats in seconds.
fromColorstring'from-indigo-500'Starting color of the beam gradient.
viaColorstring'via-purple-500'Middle color of the beam gradient.
toColorstring'to-transparent'Ending color of the beam gradient.
Copyright © 2026