Workspace / effect / overlay

Glitch

Broadcast glitch bursts that tear your live HTML into shifted slices with RGB splits and corrupted blocks.

Workspaceeffectoverlay

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

Tier: medium. Reduced motion: no glitch animation

Glitch.tsx
"use client";

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

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

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

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