{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dropdown-menu",
  "type": "registry:ui",
  "title": "Dropdown Menu",
  "description": "A typed menu on an index card.",
  "categories": [
    "core"
  ],
  "files": [
    {
      "path": "ui/dropdown-menu.tsx",
      "type": "registry:ui",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { DropdownMenu as MenuPrimitive } from \"radix-ui\";\n\nconst type = { fontFamily: \"var(--font-type, 'Courier New', ui-monospace, monospace)\" };\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/** A typed menu on an index card. */\nexport const DropdownMenu = MenuPrimitive.Root;\nexport const DropdownMenuTrigger = MenuPrimitive.Trigger;\nexport const DropdownMenuGroup = MenuPrimitive.Group;\nexport const DropdownMenuRadioGroup = MenuPrimitive.RadioGroup;\nexport const DropdownMenuSub = MenuPrimitive.Sub;\n\nconst surface =\n  \"paper z-50 min-w-[12rem] overflow-hidden rounded-[3px] border border-(--edge) bg-(--paper-raised) p-1 text-(--ink) shadow-[0_14px_30px_-12px_rgb(0_0_0/.45)] data-[state=open]:animate-[paper-pop-in_.14s_ease-out]\";\n\nconst item =\n  \"group/item relative flex cursor-pointer select-none items-center gap-2 rounded-[2px] py-2 pl-7 pr-3 text-[13.5px] outline-none data-[disabled]:pointer-events-none data-[highlighted]:bg-(--paper-sunk) data-[disabled]:opacity-45 [&_svg]:size-4\";\n\nexport function DropdownMenuContent({ className = \"\", sideOffset = 6, ...props }: React.ComponentProps<typeof MenuPrimitive.Content>) {\n  const [anchor, container] = usePaperContainer();\n  return (\n    <>\n      <span ref={anchor} hidden />\n      <MenuPrimitive.Portal container={container}>\n        <MenuPrimitive.Content sideOffset={sideOffset} data-paper-motion className={`${surface} origin-(--radix-dropdown-menu-content-transform-origin) ${className}`} {...props} />\n      </MenuPrimitive.Portal>\n    </>\n  );\n}\n\nexport function DropdownMenuItem({\n  className = \"\",\n  style,\n  variant = \"default\",\n  children,\n  ...props\n}: React.ComponentProps<typeof MenuPrimitive.Item> & { variant?: \"default\" | \"danger\" }) {\n  return (\n    <MenuPrimitive.Item\n      className={`${item} ${variant === \"danger\" ? \"text-(--danger)\" : \"\"} ${className}`}\n      style={{ ...type, ...style }}\n      {...props}\n    >\n      {/* pen mark on the highlighted line */}\n      <span aria-hidden className=\"absolute left-2 text-(--pen) opacity-0 transition-opacity group-data-[highlighted]/item:opacity-100\">\n        ›\n      </span>\n      {children}\n    </MenuPrimitive.Item>\n  );\n}\n\nconst Tick = () => (\n  <svg viewBox=\"0 0 26 26\" className=\"overflow-visible text-(--pen)\" aria-hidden>\n    <path d=\"M5 14 C 7 15.5, 9 18, 10.5 20.5 C 13 14, 17 8, 23 2.5\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"3\" strokeLinecap=\"round\" />\n  </svg>\n);\n\nexport function DropdownMenuCheckboxItem({ className = \"\", style, children, ...props }: React.ComponentProps<typeof MenuPrimitive.CheckboxItem>) {\n  return (\n    <MenuPrimitive.CheckboxItem className={`${item} ${className}`} style={{ ...type, ...style }} {...props}>\n      <span className=\"absolute left-1.5 flex size-4 items-center justify-center\">\n        <MenuPrimitive.ItemIndicator>\n          <Tick />\n        </MenuPrimitive.ItemIndicator>\n      </span>\n      {children}\n    </MenuPrimitive.CheckboxItem>\n  );\n}\n\nexport function DropdownMenuRadioItem({ className = \"\", style, children, ...props }: React.ComponentProps<typeof MenuPrimitive.RadioItem>) {\n  return (\n    <MenuPrimitive.RadioItem className={`${item} ${className}`} style={{ ...type, ...style }} {...props}>\n      <span className=\"absolute left-2 flex size-3 items-center justify-center\">\n        <MenuPrimitive.ItemIndicator>\n          <span className=\"block size-2 bg-(--pen)\" style={{ borderRadius: \"55% 45% 50% 50% / 45% 55% 48% 52%\" }} />\n        </MenuPrimitive.ItemIndicator>\n      </span>\n      {children}\n    </MenuPrimitive.RadioItem>\n  );\n}\n\nexport function DropdownMenuLabel({ className = \"\", style, ...props }: React.ComponentProps<typeof MenuPrimitive.Label>) {\n  return (\n    <MenuPrimitive.Label\n      className={`px-3 pb-1 pt-2 text-[10px] font-bold uppercase tracking-[0.2em] text-(--ink-muted) ${className}`}\n      style={{ ...type, ...style }}\n      {...props}\n    />\n  );\n}\n\nexport function DropdownMenuSeparator({ className = \"\", ...props }: React.ComponentProps<typeof MenuPrimitive.Separator>) {\n  return <MenuPrimitive.Separator className={`-mx-1 my-1 border-t border-dashed border-(--edge) ${className}`} {...props} />;\n}\n\nexport function DropdownMenuShortcut({ className = \"\", ...props }: React.HTMLAttributes<HTMLSpanElement>) {\n  return <span className={`ml-auto pl-4 text-[11px] tracking-[0.1em] text-(--ink-faint) ${className}`} {...props} />;\n}\n\nexport function DropdownMenuSubTrigger({ className = \"\", style, children, ...props }: React.ComponentProps<typeof MenuPrimitive.SubTrigger>) {\n  return (\n    <MenuPrimitive.SubTrigger className={`${item} data-[state=open]:bg-(--paper-sunk) ${className}`} style={{ ...type, ...style }} {...props}>\n      {children}\n      <span aria-hidden className=\"ml-auto pl-4 text-(--ink-muted)\">\n        ›\n      </span>\n    </MenuPrimitive.SubTrigger>\n  );\n}\n\nexport function DropdownMenuSubContent({ className = \"\", ...props }: React.ComponentProps<typeof MenuPrimitive.SubContent>) {\n  const [anchor, container] = usePaperContainer();\n  return (\n    <>\n      <span ref={anchor} hidden />\n      <MenuPrimitive.Portal container={container}>\n        <MenuPrimitive.SubContent data-paper-motion className={`${surface} ${className}`} {...props} />\n      </MenuPrimitive.Portal>\n    </>\n  );\n}\n"
    }
  ],
  "dependencies": [
    "radix-ui"
  ]
}