{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "envelope",
  "title": "Envelope",
  "author": "VenusUI",
  "description": "A sealed envelope that opens on hover or click: the flap folds back and the letter slides out.",
  "files": [
    {
      "path": "registry/default/ui/envelope.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface EnvelopeProps extends Omit<React.ComponentProps<\"div\">, \"children\"> {\n  /** The letter. Any content, including links and buttons. */\n  children: React.ReactNode\n  /** Names the envelope for screen readers, e.g. \"Invitation from Maya\". */\n  label: string\n  /** Shown on the front, e.g. the recipient's name. */\n  to?: string\n  /** Envelope color: any CSS color. Shades for the flap and pocket are mixed from it. */\n  color?: string\n  /** Controlled open state. Leave unset to open on hover and toggle on click. */\n  open?: boolean\n  defaultOpen?: boolean\n  onOpenChange?: (open: boolean) => void\n}\n\n/**\n * An envelope that opens when hovered (or clicked, tapped, or toggled with\n * Enter or Space): the flap folds back and the letter slides up out of it.\n * The letter is hidden from keyboard and screen readers until it's out.\n */\nfunction Envelope({\n  children,\n  label,\n  to,\n  color = \"oklch(0.93 0.035 75)\",\n  open: openProp,\n  defaultOpen = false,\n  onOpenChange,\n  className,\n  style,\n  ...props\n}: EnvelopeProps) {\n  const [hovered, setHovered] = React.useState(false)\n  const [pinned, setPinned] = React.useState(defaultOpen)\n  const open = openProp ?? (hovered || pinned)\n  const letterId = React.useId()\n\n  return (\n    <div\n      data-slot=\"envelope\"\n      data-open={open || undefined}\n      onPointerEnter={(event) => event.pointerType !== \"touch\" && setHovered(true)}\n      onPointerLeave={(event) => event.pointerType !== \"touch\" && setHovered(false)}\n      className={cn(\"group/envelope relative w-80 pt-[56%] select-none\", className)}\n      style={\n        {\n          \"--env\": color,\n          \"--env-dark\": `color-mix(in oklch, ${color} 88%, black)`,\n          \"--env-darker\": `color-mix(in oklch, ${color} 80%, black)`,\n          ...style,\n        } as React.CSSProperties\n      }\n      {...props}\n    >\n      <div className=\"relative aspect-[3/2] w-full perspective-[900px]\">\n        {/* Inside back of the envelope */}\n        <div aria-hidden=\"true\" className=\"absolute inset-0 rounded-md bg-(--env-darker) shadow-[0_24px_40px_-24px_rgb(0_0_0/0.45)]\" />\n\n        {/* The letter, slid up out of the pocket when open. */}\n        <div\n          id={letterId}\n          inert={!open}\n          className={cn(\n            \"absolute inset-x-[5%] top-[6%] bottom-[4%] z-10 overflow-hidden rounded-sm bg-white p-[6%] text-left text-neutral-800 shadow-[0_2px_8px_rgb(0_0_0/0.15)]\",\n            \"transition-transform duration-500 ease-[cubic-bezier(0.34,1.25,0.64,1)] motion-reduce:transition-none\",\n            \"delay-0 group-data-open/envelope:-translate-y-[88%] group-data-open/envelope:delay-200\"\n          )}\n        >\n          {children}\n        </div>\n\n        {/* Front pocket: left, right and bottom folds. */}\n        <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 z-20\">\n          <div className=\"absolute inset-0 rounded-md bg-(--env-dark) [clip-path:polygon(0_0,52%_55%,0_100%)]\" />\n          <div className=\"absolute inset-0 rounded-md bg-(--env-dark) [clip-path:polygon(100%_0,48%_55%,100%_100%)]\" />\n          <div className=\"absolute inset-0 rounded-md bg-(--env) shadow-[0_-1px_0_rgb(255_255_255/0.5)_inset] [clip-path:polygon(0_100%,50%_42%,100%_100%)]\" />\n          {to ? (\n            <p className=\"absolute inset-x-0 bottom-[14%] text-center font-serif text-sm text-neutral-700/80 italic\">{to}</p>\n          ) : null}\n        </div>\n\n        {/* Flap: folds back (behind the letter) when open. The toggle sits on it. */}\n        <div\n          className={cn(\n            \"absolute inset-x-0 top-0 z-30 h-[58%] origin-top transform-3d\",\n            \"transition-[transform,z-index] duration-300 ease-out motion-reduce:transition-none\",\n            \"delay-300 group-data-open/envelope:z-0 group-data-open/envelope:[transform:rotateX(180deg)] group-data-open/envelope:delay-0\"\n          )}\n        >\n          <div aria-hidden=\"true\" className=\"absolute inset-0 bg-(--env) drop-shadow-[0_2px_2px_rgb(0_0_0/0.12)] [clip-path:polygon(0_0,100%_0,50%_100%)] backface-hidden\" />\n          <div aria-hidden=\"true\" className=\"absolute inset-0 bg-(--env-dark) [clip-path:polygon(0_0,100%_0,50%_100%)] [transform:rotateY(180deg)] backface-hidden\" />\n          {/* Wax seal */}\n          <span\n            aria-hidden=\"true\"\n            className=\"absolute top-[86%] left-1/2 grid size-9 -translate-1/2 place-items-center rounded-full bg-radial-[at_35%_30%] from-rose-500 to-rose-800 font-serif text-sm text-rose-100 shadow-[0_2px_4px_rgb(0_0_0/0.35)] transition-opacity duration-200 group-data-open/envelope:opacity-0\"\n          >\n            ✦\n          </span>\n        </div>\n\n        {/* The toggle covers the closed envelope. */}\n        <button\n          type=\"button\"\n          aria-label={label}\n          aria-expanded={open}\n          aria-controls={letterId}\n          onClick={() => {\n            setPinned(!pinned)\n            onOpenChange?.(!pinned)\n          }}\n          className=\"absolute inset-0 z-40 cursor-pointer rounded-md outline-none focus-visible:ring-3 focus-visible:ring-ring/50 group-data-open/envelope:top-[60%]\"\n        />\n      </div>\n    </div>\n  )\n}\n\nexport { Envelope }\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "interactive",
    "animations",
    "cards"
  ],
  "type": "registry:ui"
}