Workspace / effect / three

Shatter

Breaks your live HTML into 3D glass shards that lift, float, and refract around the cursor, with perspective and soft shadows.

Workspaceeffectthree

npx shadcn@latest add @pax-sh/shatter-reactlocal only

Tier: high. Reduced motion: flat content

Shatter.tsx
"use client";

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

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

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

  useEffect(() => {
    const target = rootRef.current;
    if (!target) return;
    const instance = shatterEffect.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="shatter">
      {props.children}
    </div>
  );
}