{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tooltip",
  "type": "registry:ui",
  "title": "Tooltip",
  "description": "A sticky note that appears on hover.",
  "categories": [
    "core"
  ],
  "files": [
    {
      "path": "ui/tooltip.tsx",
      "type": "registry:ui",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { Tooltip as TooltipPrimitive } from \"radix-ui\";\n\nconst NOTES = {\n  yellow: \"#fff1a1\",\n  pink: \"#ffd3dd\",\n  blue: \"#d2e9ff\",\n  green: \"#d8f4c8\",\n} as const;\n\n// Popups render in a layer on <body> that copies the paper type of the nearest [data-paper]\n// element (and follows it if it changes). That keeps their theme without trapping them inside the\n// container's stacking context, so sticky headers can't cover them.\nfunction usePaperContainer() {\n  const anchor = React.useRef<HTMLSpanElement>(null);\n  const [container, setContainer] = React.useState<HTMLElement | undefined>();\n  React.useEffect(() => {\n    const source = anchor.current?.closest<HTMLElement>(\"[data-paper]\");\n    if (!source || source === document.documentElement) return;\n    const layer = document.createElement(\"div\");\n    layer.setAttribute(\"data-paper-layer\", \"\");\n    const sync = () => layer.setAttribute(\"data-paper\", source.getAttribute(\"data-paper\") ?? \"\");\n    sync();\n    document.body.appendChild(layer);\n    const observer = new MutationObserver(sync);\n    observer.observe(source, { attributes: true, attributeFilter: [\"data-paper\"] });\n    setContainer(layer);\n    return () => {\n      observer.disconnect();\n      layer.remove();\n    };\n  }, []);\n  return [anchor, container] as const;\n}\n\n/** Wrap your app (or a section) once to share hover delays between tooltips. */\nexport function TooltipProvider({ delayDuration = 200, ...props }: React.ComponentProps<typeof TooltipPrimitive.Provider>) {\n  return <TooltipPrimitive.Provider delayDuration={delayDuration} {...props} />;\n}\n\n/** A sticky note that appears on hover. Includes its own provider, so it works standalone. */\nexport function Tooltip(props: React.ComponentProps<typeof TooltipPrimitive.Root>) {\n  return (\n    <TooltipProvider>\n      <TooltipPrimitive.Root {...props} />\n    </TooltipProvider>\n  );\n}\n\nexport const TooltipTrigger = TooltipPrimitive.Trigger;\n\nexport function TooltipContent({\n  className = \"\",\n  style,\n  sideOffset = 8,\n  note = \"yellow\",\n  children,\n  ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Content> & { note?: keyof typeof NOTES }) {\n  const [anchor, container] = usePaperContainer();\n  return (\n    <>\n      <span ref={anchor} hidden />\n      <TooltipPrimitive.Portal container={container}>\n        <TooltipPrimitive.Content\n          sideOffset={sideOffset}\n          data-paper-motion\n          className={`z-50 max-w-[240px] origin-(--radix-tooltip-content-transform-origin) animate-[paper-pop-in_.14s_ease-out] ${className}`}\n          {...props}\n        >\n          <div\n            className=\"rotate-[-1.5deg] px-3.5 py-2 text-[18px] leading-tight\"\n            style={{\n              background: `linear-gradient(180deg, color-mix(in srgb, ${NOTES[note]} 88%, #000) 0, ${NOTES[note]} 18%)`,\n              color: \"#2a2a4a\",\n              fontFamily: \"var(--font-hand, 'Bradley Hand', 'Segoe Print', cursive)\",\n              boxShadow: \"0 1px 1px rgb(0 0 0 / .1), 2px 6px 12px -4px rgb(0 0 0 / .35)\",\n              borderBottomRightRadius: \"14px 3px\",\n              ...style,\n            }}\n          >\n            {children}\n          </div>\n        </TooltipPrimitive.Content>\n      </TooltipPrimitive.Portal>\n    </>\n  );\n}\n"
    }
  ],
  "dependencies": [
    "radix-ui"
  ]
}