Workspace / effect / three

Particle Object

Rebuilds any 3D model, SVG, or image as particles that scatter around the cursor and spring back into shape.

Workspaceeffectthree

npx shadcn@latest add @pax-sh/particle-object-reactlocal only

Tier: high. Reduced motion: solid object

ParticleObject.tsx
"use client";

import { useEffect, useRef } from "react";
import { particleObjectEffect } from "@pax-sh/effects";

export interface ParticleObjectProps {
  className?: string;
  reducedMotion?: boolean;
  tier?: "low" | "medium" | "high";
  children?: React.ReactNode;
}

export function ParticleObject(props: ParticleObjectProps) {
  const rootRef = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const target = rootRef.current;
    if (!target) return;
    const instance = particleObjectEffect.mount(target, {
      className: props.className,
      reducedMotion: props.reducedMotion,
      tier: props.tier,
    });
    return () => instance.dispose();
  }, [props.className, props.reducedMotion, props.tier]);

  return (
    <div ref={rootRef} className={props.className} data-pax-effect="particle-object">
      {props.children}
    </div>
  );
}