{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dot-grid",
  "title": "Dot grid",
  "description": "A dot or line grid background with a radial, top or edge fade and an optional glow that follows the pointer. Pure CSS.",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/components/backgrounds/dot-grid.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\n\nconst CSS = `\n.pc-dot-grid { --pc-dg-x: 50%; --pc-dg-y: 50% }\n.pc-dot-grid-highlight {\n  opacity: 0; transition: opacity 0.4s ease;\n  -webkit-mask-image: radial-gradient(var(--pc-dg-r, 180px) circle at var(--pc-dg-x) var(--pc-dg-y), #000, transparent);\n  mask-image: radial-gradient(var(--pc-dg-r, 180px) circle at var(--pc-dg-x) var(--pc-dg-y), #000, transparent);\n}\n.pc-dot-grid[data-pointer] .pc-dot-grid-highlight { opacity: 1 }\n@media (prefers-reduced-motion: reduce) { .pc-dot-grid-highlight { transition: none } }\n`\n\nconst FADES = {\n  radial: \"radial-gradient(ellipse 70% 65% at 50% 50%, #000 30%, transparent 100%)\",\n  top: \"linear-gradient(to bottom, #000 10%, transparent 90%)\",\n  bottom: \"linear-gradient(to top, #000 10%, transparent 90%)\",\n  edges: \"linear-gradient(to right, transparent, #000 15%, #000 85%, transparent), linear-gradient(to bottom, transparent, #000 15%, #000 85%, transparent)\",\n  none: \"none\",\n} as const\n\nexport type DotGridProps = React.HTMLAttributes<HTMLDivElement> & {\n  /** \"dots\" is a dot pattern; \"lines\" a square line grid. */\n  variant?: \"dots\" | \"lines\"\n  /** Distance between dots or lines, in px. */\n  gap?: number\n  /** Dot radius or line width, in px. */\n  size?: number\n  /** Pattern color. Defaults to the foreground at low opacity, so it works in light and dark. */\n  color?: string\n  /** Where the pattern fades out: \"radial\" | \"top\" | \"bottom\" | \"edges\" | \"none\". */\n  fade?: keyof typeof FADES\n  /** Brighten the pattern around the pointer (listens on the parent element). */\n  highlight?: boolean\n  /** Color of the pattern inside the pointer highlight. Defaults to the theme's --chart-1. */\n  highlightColor?: string\n  /** Radius of the pointer highlight, in px. */\n  highlightRadius?: number\n}\n\nfunction pattern(variant: \"dots\" | \"lines\", size: number, color: string) {\n  if (variant === \"dots\") return `radial-gradient(circle, ${color} ${size}px, transparent ${size + 0.6}px)`\n  return `linear-gradient(to right, ${color} ${size}px, transparent ${size}px), linear-gradient(to bottom, ${color} ${size}px, transparent ${size}px)`\n}\n\n/**\n * A dot or line grid for the back of a section, with a fade mask and an optional highlight that follows the\n * pointer. Pure CSS; place it inside a `relative` parent.\n */\nexport function DotGrid({\n  variant = \"dots\",\n  gap = 22,\n  size = 1,\n  color,\n  fade = \"radial\",\n  highlight = false,\n  highlightColor = \"color-mix(in oklch, var(--chart-1) 90%, transparent)\",\n  highlightRadius = 180,\n  className,\n  style,\n  ...props\n}: DotGridProps) {\n  const ref = React.useRef<HTMLDivElement>(null)\n  const base = color ?? `color-mix(in oklch, var(--foreground) ${variant === \"dots\" ? 22 : 9}%, transparent)`\n\n  React.useEffect(() => {\n    const el = ref.current\n    const host = el?.parentElement\n    if (!el || !host || !highlight) return\n    let frame = 0\n    const move = (e: PointerEvent) => {\n      cancelAnimationFrame(frame)\n      frame = requestAnimationFrame(() => {\n        const r = el.getBoundingClientRect()\n        el.style.setProperty(\"--pc-dg-x\", `${e.clientX - r.left}px`)\n        el.style.setProperty(\"--pc-dg-y\", `${e.clientY - r.top}px`)\n        el.setAttribute(\"data-pointer\", \"\")\n      })\n    }\n    const leave = () => {\n      cancelAnimationFrame(frame)\n      el.removeAttribute(\"data-pointer\")\n    }\n    host.addEventListener(\"pointermove\", move)\n    host.addEventListener(\"pointerleave\", leave)\n    return () => {\n      cancelAnimationFrame(frame)\n      host.removeEventListener(\"pointermove\", move)\n      host.removeEventListener(\"pointerleave\", leave)\n    }\n  }, [highlight])\n\n  const layer: React.CSSProperties = {\n    backgroundSize: `${gap}px ${gap}px`,\n    backgroundPosition: variant === \"dots\" ? \"center\" : `calc(50% - ${size / 2}px) calc(50% - ${size / 2}px)`,\n  }\n  const mask = FADES[fade]\n\n  return (\n    <div\n      ref={ref}\n      aria-hidden=\"true\"\n      className={cn(\"pc-dot-grid pointer-events-none absolute inset-0 overflow-hidden\", className)}\n      style={{\n        ...style,\n        [\"--pc-dg-r\" as string]: `${highlightRadius}px`,\n        maskImage: mask,\n        WebkitMaskImage: mask,\n        ...(fade === \"edges\" ? { maskComposite: \"intersect\", WebkitMaskComposite: \"source-in\" } : {}),\n      }}\n      {...props}\n    >\n      <style href=\"pc-dot-grid\" precedence=\"default\">\n        {CSS}\n      </style>\n      <div className=\"absolute inset-0\" style={{ ...layer, backgroundImage: pattern(variant, size, base) }} />\n      {highlight && (\n        <div\n          className=\"pc-dot-grid-highlight absolute inset-0\"\n          style={{ ...layer, backgroundImage: pattern(variant, variant === \"dots\" ? size + 0.4 : size, highlightColor) }}\n        />\n      )}\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/dot-grid.tsx"
    }
  ],
  "categories": [
    "components",
    "backgrounds"
  ],
  "type": "registry:component"
}