{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "edge-fade-blur",
  "title": "Edge Fade Blur",
  "description": "A scroll area whose content melts away at the edges: a stack of backdrop blurs ramps up smoothly toward the top and bottom while the content fades out, and each edge only appears when there's more to scroll that way.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/edge-fade-blur/edge-fade-blur.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface EdgeFadeBlurProps extends React.ComponentPropsWithoutRef<\"div\"> {\n  /** Which edges blur. */\n  edges?: \"both\" | \"top\" | \"bottom\";\n  /** Height of the blurred band at each edge, in px. */\n  size?: number;\n  /** Blur at the very edge, in px; it halves with each step inward. */\n  maxBlur?: number;\n  /** Number of blur steps; more steps make a smoother ramp. */\n  steps?: number;\n  /** Also fade the content out toward each edge. */\n  fade?: boolean;\n  /** Height of the scroll area. */\n  height?: number | string;\n  /** Classes for the inner scroll area. */\n  contentClassName?: string;\n}\n\nfunction band(edge: \"top\" | \"bottom\", size: number, maxBlur: number, steps: number) {\n  // Stacked layers, each blurring twice as much as the one inside it, each faded in and out over its own slice,\n  // so the blur ramps up smoothly toward the edge instead of stopping at a hard line.\n  const layers = [];\n  for (let i = 0; i < steps; i++) {\n    const blur = maxBlur / Math.pow(2, steps - 1 - i);\n    const a = (i / (steps + 1)) * 100;\n    const b = ((i + 1) / (steps + 1)) * 100;\n    const c = ((i + 2) / (steps + 1)) * 100;\n    // Measured from the inner side of the band (0%) to the very edge (100%).\n    const dir = edge === \"top\" ? \"to top\" : \"to bottom\";\n    const mask = `linear-gradient(${dir}, transparent ${a}%, #000 ${b}%, #000 ${c}%, ${i === steps - 1 ? \"#000\" : \"transparent\"} ${i === steps - 1 ? 100 : Math.min(100, c + 100 / (steps + 1))}%)`;\n    layers.push(\n      <span\n        key={i}\n        className=\"absolute inset-0\"\n        style={{ backdropFilter: `blur(${blur.toFixed(2)}px)`, WebkitBackdropFilter: `blur(${blur.toFixed(2)}px)`, maskImage: mask, WebkitMaskImage: mask }}\n      />,\n    );\n  }\n  return (\n    <div aria-hidden=\"true\" className={cn(\"pointer-events-none absolute inset-x-0 z-10 transition-opacity duration-300\", edge === \"top\" ? \"top-0\" : \"bottom-0\")} style={{ height: size }}>\n      {layers}\n    </div>\n  );\n}\n\nexport function EdgeFadeBlur({ edges = \"both\", size = 96, maxBlur = 12, steps = 6, fade = true, height = 420, contentClassName, className, style, children, ...props }: EdgeFadeBlurProps) {\n  const scrollRef = React.useRef<HTMLDivElement>(null);\n  // Hide an edge's blur when there's nothing past that edge to hide.\n  const [atTop, setAtTop] = React.useState(true);\n  const [atBottom, setAtBottom] = React.useState(false);\n\n  React.useEffect(() => {\n    const el = scrollRef.current;\n    if (!el) return;\n    const update = () => {\n      setAtTop(el.scrollTop <= 1);\n      setAtBottom(el.scrollTop + el.clientHeight >= el.scrollHeight - 1);\n    };\n    update();\n    el.addEventListener(\"scroll\", update, { passive: true });\n    const ro = new ResizeObserver(update);\n    ro.observe(el);\n    if (el.firstElementChild) ro.observe(el.firstElementChild);\n    return () => {\n      el.removeEventListener(\"scroll\", update);\n      ro.disconnect();\n    };\n  }, []);\n\n  const top = edges !== \"bottom\";\n  const bottom = edges !== \"top\";\n  const topSize = top && !atTop ? size : 0;\n  const bottomSize = bottom && !atBottom ? size : 0;\n  const mask = fade ? `linear-gradient(to bottom, transparent 0, #000 ${topSize * 0.75}px, #000 calc(100% - ${bottomSize * 0.75}px), transparent 100%)` : undefined;\n\n  return (\n    <div className={cn(\"relative overflow-hidden\", className)} style={{ height, ...style }} {...props}>\n      <div\n        ref={scrollRef}\n        tabIndex={0}\n        className={cn(\"h-full overflow-y-auto overscroll-contain outline-none focus-visible:ring-2 focus-visible:ring-inset\", contentClassName)}\n        style={{ maskImage: mask, WebkitMaskImage: mask, transition: \"mask-image 300ms\" }}\n      >\n        <div>{children}</div>\n      </div>\n      {top && <div style={{ opacity: atTop ? 0 : 1 }} className=\"transition-opacity duration-300\">{band(\"top\", size, maxBlur, steps)}</div>}\n      {bottom && <div style={{ opacity: atBottom ? 0 : 1 }} className=\"transition-opacity duration-300\">{band(\"bottom\", size, maxBlur, steps)}</div>}\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}