Workspace / effect / overlay

Retro Dither

A retro dither lens that pixelates your live HTML around the cursor.

Workspaceeffectoverlay

npx shadcn@latest add @pax-sh/retro-dither-reactlocal only

Tier: low. Reduced motion: uniform dither

RetroDither.tsx
"use client";

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

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

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

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