Modus UI

Click Spark

Web (React)

A physics-based canvas effect that bursts colorful sparks wherever the user clicks.

A physics-based canvas effect that creates a burst of colorful sparks originating from the exact coordinates of a user's click.

Click Anywhere

Click inside this bounding box to trigger the canvas spark effect!

Installation

CLI

npx @modus-ui/cli add click-spark

Manual

  1. Copy the code from the component tab.
  2. Create a file at components/ui/click-spark.tsx.
  3. Paste the code.

Usage

Wrap any container with ClickSpark.

tsx
import { ClickSpark } from "@/components/ui/click-spark";

export default function Example() {
  return (
    <ClickSpark sparkColor="hsl(var(--primary))" sparkCount={8}>
      <button>Click me for sparks</button>
    </ClickSpark>
  );
}

Props

PropTypeDefaultDescription
sparkColorstring"hsl(var(--primary))"Colour of the sparks.
sparkSizenumber10Length of each spark in pixels.
sparkRadiusnumber25Distance the sparks travel in pixels.
sparkCountnumber8Number of sparks per click.
durationnumber500Milliseconds the sparks last.
easing"linear" | "ease-in" | "ease-out" | "ease-in-out""ease-out"Easing of the spark motion.
extraScalenumber1Multiplier for spark distance and size.

Comments

  • No comments yet.