{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"share-button-expand","type":"registry:component","title":"Share Button Expand","description":"A share button that springs open into a row of targets: X, LinkedIn, email and a copy-link that only confirms when the clipboard write worked. A light follows the pointer, a lens slides between options, and the device share sheet joins in where it exists. No dependencies.","dependencies":[],"registryDependencies":[],"files":[{"path":"components/viberdy/share-button-expand.tsx","content":"\"use client\";\n\nimport { useEffect, useRef, useState, useSyncExternalStore } from \"react\";\n\nexport type ShareTarget = \"x\" | \"linkedin\" | \"email\" | \"copy\";\n\nexport interface ShareButtonExpandProps {\n  /** The link to share. Defaults to the current page address. */\n  url?: string;\n  /** Subject for email, and the post text when `text` is empty. */\n  title?: string;\n  /** Short post text for X and the email body. */\n  text?: string;\n  /** Which share targets to show, in order. */\n  targets?: ShareTarget[];\n  /** Add a \"More\" button that opens the device share sheet when the browser has one. */\n  native?: boolean;\n  /** Start expanded. */\n  defaultOpen?: boolean;\n  /** \"auto\" inherits the page text colour, \"light\" and \"dark\" paint their own surface. */\n  tone?: \"auto\" | \"light\" | \"dark\";\n  /** Hover, focus and success colour. */\n  accent?: string;\n  onOpenChange?: (open: boolean) => void;\n  /** Called after a target is used. For \"copy\" it only fires when the copy worked. */\n  onShare?: (target: ShareTarget | \"native\") => void;\n  className?: string;\n}\n\nconst DEFAULT_TARGETS: ShareTarget[] = [\"x\", \"email\", \"copy\"];\nconst ACCENT_RE = /^(#[0-9a-f]{3,8}|(rgb|hsl)a?\\([0-9a-z%.,\\s/-]+\\))$/i;\n\nconst CSS = `\n.sbx-root{--sbx-ease:cubic-bezier(.34,1.56,.64,1);--sbx-soft:cubic-bezier(.22,1,.36,1);color:var(--sbx-text,inherit)}\n.sbx-tone-auto{--sbx-fg:color-mix(in srgb,currentColor 62%,transparent);--sbx-strong:currentColor;--sbx-bd:color-mix(in srgb,currentColor 17%,transparent);--sbx-bg:color-mix(in srgb,currentColor 4%,transparent);--sbx-sh:none}\n.sbx-tone-light{--sbx-text:#525252;--sbx-fg:#6b6b6b;--sbx-strong:#171717;--sbx-bd:#e5e5e5;--sbx-bg:#fff;--sbx-sh:0 1px 2px rgba(0,0,0,.05),0 14px 28px -16px rgba(0,0,0,.22)}\n.sbx-tone-dark{--sbx-text:#e5e7eb;--sbx-fg:rgba(255,255,255,.62);--sbx-strong:#fff;--sbx-bd:rgba(255,255,255,.12);--sbx-bg:#0d0e11;--sbx-sh:inset 0 1px 0 rgba(255,255,255,.06),0 18px 36px -18px rgba(0,0,0,.9)}\n.sbx-pill{position:relative;display:inline-flex;align-items:center;padding:.25em;border-radius:999px;border:1px solid var(--sbx-bd);background:var(--sbx-bg);box-shadow:var(--sbx-sh);border-color:var(--sbx-bd)}\n.sbx-pill::before{content:\"\";position:absolute;inset:0;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity .35s ease;background:radial-gradient(9em circle at var(--sbx-mx,50%) var(--sbx-my,0%),color-mix(in srgb,var(--sbx-accent) 20%,transparent),transparent 70%)}\n.sbx-pill:hover::before{opacity:1}\n.sbx-btn{position:relative;display:inline-flex;align-items:center;justify-content:center;flex:none;width:2.5em;height:2.5em;padding:0;margin:0;border:0;border-radius:999px;background:transparent;color:var(--sbx-fg);font:inherit;line-height:1;text-decoration:none;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:color .2s ease}\n.sbx-btn:hover{color:var(--sbx-accent)}\n.sbx-btn:focus-visible{outline:2px solid var(--sbx-accent);outline-offset:2px;border-radius:999px}\n.sbx-face{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:100%;border-radius:999px;transition:transform .18s var(--sbx-soft)}\n.sbx-btn:active .sbx-face{transform:scale(.88)}\n.sbx-ic{position:absolute;inset:0;margin:auto;width:1.15em;height:1.15em;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;transition:transform .42s var(--sbx-ease),opacity .2s ease}\n.sbx-mono{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:.92em;font-weight:700;letter-spacing:-.02em;font-family:ui-sans-serif,system-ui,sans-serif}\n.sbx-trigger .sbx-ic-close{opacity:0;transform:rotate(-90deg) scale(.4)}\n.sbx-trigger[aria-expanded=\"true\"] .sbx-ic-share{opacity:0;transform:rotate(90deg) scale(.4)}\n.sbx-trigger[aria-expanded=\"true\"] .sbx-ic-close{opacity:1;transform:none}\n.sbx-trigger[aria-expanded=\"true\"]{color:var(--sbx-strong)}\n.sbx-clip{overflow:hidden;width:0;padding:.25em 0;margin:-.25em 0;transition:width .56s var(--sbx-ease)}\n.sbx-clip[data-open=\"true\"]{width:auto}\n.sbx-track{position:relative;display:flex;align-items:center;width:max-content;padding:0 .125em 0 0;gap:.125em}\n.sbx-lens{position:absolute;top:0;left:0;height:100%;border-radius:999px;pointer-events:none;opacity:0;background:color-mix(in srgb,var(--sbx-accent) 15%,transparent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--sbx-accent) 28%,transparent);transition:transform .34s var(--sbx-ease),width .34s var(--sbx-soft),opacity .2s ease}\n.sbx-item{opacity:0;transform:translateX(-.6em) scale(.5);filter:blur(4px);transition:transform .22s ease calc((var(--n) - var(--i)) * 28ms),opacity .16s ease calc((var(--n) - var(--i)) * 28ms),filter .16s ease calc((var(--n) - var(--i)) * 28ms),color .2s ease}\n.sbx-clip[data-open=\"true\"] .sbx-item{opacity:1;transform:none;filter:none;transition:transform .5s var(--sbx-ease) calc(var(--i) * 48ms + 60ms),opacity .24s ease calc(var(--i) * 48ms + 60ms),filter .3s ease calc(var(--i) * 48ms + 60ms),color .2s ease}\n.sbx-copy .sbx-ic-check{opacity:0;transform:scale(.4)}\n.sbx-copy .sbx-ic-check path{stroke-dasharray:1;stroke-dashoffset:1;transition:stroke-dashoffset .4s ease .08s}\n.sbx-copy[data-state=\"ok\"]{color:var(--sbx-accent)}\n.sbx-copy[data-state=\"ok\"] .sbx-ic-link{opacity:0;transform:scale(.4)}\n.sbx-copy[data-state=\"ok\"] .sbx-ic-check{opacity:1;transform:none}\n.sbx-copy[data-state=\"ok\"] .sbx-ic-check path{stroke-dashoffset:0}\n.sbx-cap{position:absolute;left:50%;top:100%;margin-top:.75em;transform:translate(-50%,-.3em);display:inline-flex;align-items:center;gap:.5em;padding:.3em .8em;border-radius:999px;font-size:.75em;line-height:1.3;white-space:nowrap;pointer-events:none;opacity:0;color:var(--sbx-fg);transition:opacity .18s ease,transform .3s var(--sbx-soft)}\n.sbx-cap[data-on=\"true\"]{opacity:1;transform:translate(-50%,0)}\n.sbx-cap[data-kind=\"ok\"]{color:var(--sbx-strong)}\n.sbx-cap[data-kind=\"err\"]{color:#f87171}\n.sbx-dot{width:.5em;height:.5em;border-radius:999px;background:var(--sbx-accent)}\n.sbx-cap[data-kind=\"err\"] .sbx-dot{background:#f87171}\n.sbx-cap[data-kind=\"hint\"] .sbx-dot{display:none}\n@media (prefers-reduced-motion:reduce){\n.sbx-clip,.sbx-lens,.sbx-pill::before,.sbx-cap,.sbx-face{transition:none}\n.sbx-item,.sbx-clip[data-open=\"true\"] .sbx-item{transform:none;filter:none;transition:opacity .15s ease}\n.sbx-ic,.sbx-copy .sbx-ic-check path{transition:opacity .15s ease}\n.sbx-trigger .sbx-ic-close,.sbx-trigger[aria-expanded=\"true\"] .sbx-ic-share,.sbx-copy[data-state=\"ok\"] .sbx-ic-link,.sbx-copy .sbx-ic-check{transform:none}\n.sbx-cap,.sbx-cap[data-on=\"true\"]{transform:translate(-50%,0)}\n}\n`;\n\nconst noopSubscribe = () => () => {};\nconst getHref = () => window.location.href;\nconst getServerHref = () => \"\";\nconst canNativeShare = () => typeof navigator !== \"undefined\" && typeof navigator.share === \"function\";\nconst noNativeShare = () => false;\n\nasync function copyText(value: string): Promise<boolean> {\n  if (!value) return false;\n  try {\n    if (navigator.clipboard && typeof navigator.clipboard.writeText === \"function\") {\n      await navigator.clipboard.writeText(value);\n      return true;\n    }\n  } catch {\n    /* fall through to the legacy path */\n  }\n  try {\n    const prev = document.activeElement as HTMLElement | null;\n    const ta = document.createElement(\"textarea\");\n    ta.value = value;\n    ta.setAttribute(\"readonly\", \"\");\n    ta.style.cssText = \"position:fixed;top:0;left:0;opacity:0;pointer-events:none\";\n    document.body.appendChild(ta);\n    ta.select();\n    ta.setSelectionRange(0, value.length);\n    const ok = document.execCommand(\"copy\");\n    ta.remove();\n    prev?.focus?.({ preventScroll: true });\n    return ok;\n  } catch {\n    return false;\n  }\n}\n\nfunction Icon({ name }: { name: \"share\" | \"close\" | \"mail\" | \"link\" | \"check\" | \"native\" }) {\n  const cls = \"sbx-ic sbx-ic-\" + (name === \"native\" ? \"nat\" : name);\n  const common = { className: cls, viewBox: \"0 0 24 24\", \"aria-hidden\": true as const, focusable: false as const };\n  if (name === \"share\")\n    return (\n      <svg {...common}>\n        <circle cx=\"18\" cy=\"5.5\" r=\"2.6\" />\n        <circle cx=\"6\" cy=\"12\" r=\"2.6\" />\n        <circle cx=\"18\" cy=\"18.5\" r=\"2.6\" />\n        <path d=\"M8.3 10.8l7.4-4.1M8.3 13.2l7.4 4.1\" />\n      </svg>\n    );\n  if (name === \"close\")\n    return (\n      <svg {...common}>\n        <path d=\"M6.5 6.5l11 11M17.5 6.5l-11 11\" />\n      </svg>\n    );\n  if (name === \"mail\")\n    return (\n      <svg {...common}>\n        <rect x=\"3\" y=\"5.5\" width=\"18\" height=\"13\" rx=\"3\" />\n        <path d=\"M4 8l8 5.6L20 8\" />\n      </svg>\n    );\n  if (name === \"link\")\n    return (\n      <svg {...common}>\n        <path d=\"M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1\" />\n        <path d=\"M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1\" />\n      </svg>\n    );\n  if (name === \"check\")\n    return (\n      <svg {...common}>\n        <path d=\"M5.5 12.5l4.2 4.2L18.5 7.8\" pathLength={1} />\n      </svg>\n    );\n  return (\n    <svg {...common}>\n      <path d=\"M12 15V4M8 8l4-4 4 4M5 13v5a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-5\" />\n    </svg>\n  );\n}\n\ntype Item = {\n  key: ShareTarget | \"native\";\n  label: string;\n  hint: string;\n  href?: string;\n  external?: boolean;\n};\n\nexport function ShareButtonExpand({\n  url,\n  title = \"\",\n  text = \"\",\n  targets = DEFAULT_TARGETS,\n  native = true,\n  defaultOpen = false,\n  tone = \"auto\",\n  accent = \"#ef4444\",\n  onOpenChange,\n  onShare,\n  className = \"\",\n}: ShareButtonExpandProps) {\n  const [open, setOpenState] = useState(defaultOpen);\n  const [hint, setHint] = useState<string | null>(null);\n  const [status, setStatus] = useState<{ kind: \"ok\" | \"err\"; text: string } | null>(null);\n  const rootRef = useRef<HTMLDivElement>(null);\n  const pillRef = useRef<HTMLDivElement>(null);\n  const clipRef = useRef<HTMLDivElement>(null);\n  const trackRef = useRef<HTMLDivElement>(null);\n  const lensRef = useRef<HTMLSpanElement>(null);\n  const triggerRef = useRef<HTMLButtonElement>(null);\n  const lensShown = useRef(false);\n  const mounted = useRef(false);\n  const timer = useRef(0);\n\n  const pageHref = useSyncExternalStore(noopSubscribe, getHref, getServerHref);\n  const nativeOk = useSyncExternalStore(noopSubscribe, canNativeShare, noNativeShare);\n  const shareUrl = url ?? pageHref;\n  const safeAccent = ACCENT_RE.test(accent.trim()) ? accent.trim() : \"#ef4444\";\n\n  const enc = encodeURIComponent;\n  const post = text || title;\n  const all: Record<ShareTarget, Item> = {\n    x: {\n      key: \"x\",\n      label: \"Share on X\",\n      hint: \"Post on X\",\n      href: \"https://x.com/intent/post?\" + (post ? \"text=\" + enc(post) + \"&\" : \"\") + \"url=\" + enc(shareUrl),\n      external: true,\n    },\n    linkedin: {\n      key: \"linkedin\",\n      label: \"Share on LinkedIn\",\n      hint: \"Share on LinkedIn\",\n      href: \"https://www.linkedin.com/sharing/share-offsite/?url=\" + enc(shareUrl),\n      external: true,\n    },\n    email: {\n      key: \"email\",\n      label: \"Share via email\",\n      hint: \"Send by email\",\n      href: \"mailto:?subject=\" + enc(title || \"Worth a look\") + \"&body=\" + enc((text ? text + \"\\n\\n\" : \"\") + shareUrl),\n    },\n    copy: { key: \"copy\", label: \"Copy link\", hint: \"Copy link\" },\n  };\n  const items: Item[] = [];\n  for (const k of targets) {\n    const it = all[k];\n    if (it && !items.some((x) => x.key === k)) items.push(it);\n  }\n  if (native && nativeOk) items.push({ key: \"native\", label: \"More share options\", hint: \"More options\" });\n  const count = items.length;\n  const copied = status?.kind === \"ok\";\n\n  function setOpen(next: boolean) {\n    setOpenState(next);\n    if (!next) {\n      setHint(null);\n      hideLens();\n    }\n    onOpenChange?.(next);\n  }\n\n  function flash(next: { kind: \"ok\" | \"err\"; text: string }) {\n    window.clearTimeout(timer.current);\n    setStatus(next);\n    timer.current = window.setTimeout(() => setStatus(null), 1900);\n  }\n\n  function moveLens(el: HTMLElement) {\n    const lens = lensRef.current;\n    if (!lens) return;\n    if (!lensShown.current) {\n      lens.style.transition = \"opacity .2s ease\";\n      lens.style.transform = \"translateX(\" + el.offsetLeft + \"px)\";\n      lens.style.width = el.offsetWidth + \"px\";\n      void lens.offsetWidth;\n      lens.style.transition = \"\";\n      lensShown.current = true;\n    } else {\n      lens.style.transform = \"translateX(\" + el.offsetLeft + \"px)\";\n      lens.style.width = el.offsetWidth + \"px\";\n    }\n    lens.style.opacity = \"1\";\n  }\n\n  function hideLens() {\n    const lens = lensRef.current;\n    if (lens) lens.style.opacity = \"0\";\n    lensShown.current = false;\n  }\n\n  function activate(el: HTMLElement, label: string) {\n    moveLens(el);\n    setHint(label);\n  }\n\n  function leaveTrack(e: React.FocusEvent | React.PointerEvent) {\n    const next = (e as React.FocusEvent).relatedTarget;\n    if (next instanceof Node && trackRef.current?.contains(next)) return;\n    if (trackRef.current?.contains(document.activeElement) && e.type === \"pointerleave\") return;\n    hideLens();\n    setHint(null);\n  }\n\n  async function activateItem(it: Item) {\n    if (it.key === \"copy\") {\n      const ok = await copyText(shareUrl);\n      if (ok) {\n        flash({ kind: \"ok\", text: \"Link copied\" });\n        onShare?.(\"copy\");\n      } else {\n        flash({ kind: \"err\", text: \"Couldn’t copy\" });\n      }\n      return;\n    }\n    if (it.key === \"native\") {\n      try {\n        await navigator.share({ title: title || undefined, text: text || undefined, url: shareUrl || undefined });\n        onShare?.(\"native\");\n        setOpen(false);\n      } catch {\n        /* dismissed the sheet */\n      }\n      return;\n    }\n    onShare?.(it.key);\n    setOpen(false);\n  }\n\n  function onPillMove(e: React.PointerEvent<HTMLDivElement>) {\n    const pill = pillRef.current;\n    if (!pill) return;\n    const r = pill.getBoundingClientRect();\n    if (!r.width) return;\n    pill.style.setProperty(\"--sbx-mx\", ((e.clientX - r.left) * (pill.offsetWidth / r.width)).toFixed(1) + \"px\");\n    pill.style.setProperty(\"--sbx-my\", ((e.clientY - r.top) * (pill.offsetHeight / r.height)).toFixed(1) + \"px\");\n  }\n\n  function onKeyDown(e: React.KeyboardEvent) {\n    if (e.key === \"Escape\" && open) {\n      e.preventDefault();\n      setOpen(false);\n      triggerRef.current?.focus();\n      return;\n    }\n    const nav = [\"ArrowRight\", \"ArrowLeft\", \"Home\", \"End\"];\n    if (!nav.includes(e.key) || !rootRef.current) return;\n    const els = Array.from(rootRef.current.querySelectorAll<HTMLElement>(\"[data-sbx-item]\")).filter(\n      (el) => !el.closest(\"[inert]\"),\n    );\n    const at = els.indexOf(document.activeElement as HTMLElement);\n    if (at < 0) return;\n    e.preventDefault();\n    let to = at;\n    if (e.key === \"ArrowRight\") to = Math.min(els.length - 1, at + 1);\n    else if (e.key === \"ArrowLeft\") to = Math.max(0, at - 1);\n    else if (e.key === \"Home\") to = 0;\n    else to = els.length - 1;\n    els[to]?.focus();\n  }\n\n  // The clip animates between 0 and the measured track width (layout pixels).\n  useEffect(() => {\n    const clip = clipRef.current;\n    const track = trackRef.current;\n    if (!clip || !track) return;\n    clip.toggleAttribute(\"inert\", !open);\n    const fit = () => {\n      clip.style.width = open ? track.offsetWidth + \"px\" : \"0px\";\n    };\n    if (!mounted.current) {\n      clip.style.transition = \"none\";\n      fit();\n      void clip.offsetWidth;\n      clip.style.transition = \"\";\n      mounted.current = true;\n    } else {\n      fit();\n    }\n    if (!open || typeof ResizeObserver === \"undefined\") return;\n    const ro = new ResizeObserver(() => {\n      clip.style.width = track.offsetWidth + \"px\";\n    });\n    ro.observe(track);\n    return () => ro.disconnect();\n  }, [open, count]);\n\n  const onOpenChangeRef = useRef(onOpenChange);\n  const hideLensRef = useRef(hideLens);\n  useEffect(() => {\n    onOpenChangeRef.current = onOpenChange;\n    hideLensRef.current = hideLens;\n  });\n\n  // Close on a press outside while open.\n  useEffect(() => {\n    if (!open) return;\n    const down = (e: PointerEvent) => {\n      if (rootRef.current && !rootRef.current.contains(e.target as Node)) {\n        setOpenState(false);\n        setHint(null);\n        hideLensRef.current();\n        onOpenChangeRef.current?.(false);\n      }\n    };\n    document.addEventListener(\"pointerdown\", down);\n    return () => document.removeEventListener(\"pointerdown\", down);\n  }, [open]);\n\n  useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  const capText = status ? status.text : hint;\n  const capKind = status ? status.kind : \"hint\";\n\n  return (\n    <>\n      <style>{CSS}</style>\n      <div\n        ref={rootRef}\n        onKeyDown={onKeyDown}\n        className={\"sbx-root sbx-tone-\" + tone + \" relative inline-flex align-middle \" + className}\n        style={{ [\"--sbx-accent\" as string]: safeAccent }}\n      >\n        <div ref={pillRef} className=\"sbx-pill\" onPointerMove={onPillMove}>\n          <button\n            ref={triggerRef}\n            type=\"button\"\n            data-sbx-item=\"\"\n            className=\"sbx-btn sbx-trigger\"\n            aria-label={open ? \"Close share options\" : \"Share\"}\n            aria-expanded={open}\n            aria-controls=\"sbx-targets\"\n            onClick={() => setOpen(!open)}\n          >\n            <span className=\"sbx-face\">\n              <Icon name=\"share\" />\n              <Icon name=\"close\" />\n            </span>\n          </button>\n          <div ref={clipRef} className=\"sbx-clip\" data-open={open} aria-hidden={!open}>\n            <div\n              ref={trackRef}\n              id=\"sbx-targets\"\n              role=\"group\"\n              aria-label=\"Share options\"\n              className=\"sbx-track\"\n              onPointerLeave={leaveTrack}\n              onBlur={leaveTrack}\n            >\n              <span ref={lensRef} className=\"sbx-lens\" aria-hidden />\n              {items.map((it, i) => {\n                const style = { [\"--i\" as string]: i, [\"--n\" as string]: count - 1 };\n                const handlers = {\n                  \"data-sbx-item\": \"\",\n                  onPointerEnter: (e: React.PointerEvent<HTMLElement>) => activate(e.currentTarget, it.hint),\n                  onFocus: (e: React.FocusEvent<HTMLElement>) => activate(e.currentTarget, it.hint),\n                  style,\n                };\n                const face =\n                  it.key === \"x\" ? (\n                    <span className=\"sbx-mono\" aria-hidden>\n                      X\n                    </span>\n                  ) : it.key === \"linkedin\" ? (\n                    <span className=\"sbx-mono\" aria-hidden>\n                      in\n                    </span>\n                  ) : it.key === \"email\" ? (\n                    <Icon name=\"mail\" />\n                  ) : it.key === \"copy\" ? (\n                    <>\n                      <Icon name=\"link\" />\n                      <Icon name=\"check\" />\n                    </>\n                  ) : (\n                    <Icon name=\"native\" />\n                  );\n                if (it.href) {\n                  return (\n                    <a\n                      key={it.key}\n                      href={it.href}\n                      {...(it.external ? { target: \"_blank\", rel: \"noopener noreferrer\" } : {})}\n                      aria-label={it.label + (it.external ? \" (opens in a new tab)\" : \"\")}\n                      className=\"sbx-btn sbx-item\"\n                      onClick={() => void activateItem(it)}\n                      {...handlers}\n                    >\n                      <span className=\"sbx-face\">{face}</span>\n                    </a>\n                  );\n                }\n                return (\n                  <button\n                    key={it.key}\n                    type=\"button\"\n                    aria-label={it.key === \"copy\" && copied ? \"Link copied\" : it.label}\n                    className={\"sbx-btn sbx-item\" + (it.key === \"copy\" ? \" sbx-copy\" : \"\")}\n                    data-state={it.key === \"copy\" && copied ? \"ok\" : undefined}\n                    onClick={() => void activateItem(it)}\n                    {...handlers}\n                  >\n                    <span className=\"sbx-face\">{face}</span>\n                  </button>\n                );\n              })}\n            </div>\n          </div>\n        </div>\n        <div className=\"sbx-cap\" role=\"status\" aria-live=\"polite\" data-on={!!capText} data-kind={capKind}>\n          <span className=\"sbx-dot\" aria-hidden />\n          {capText}\n        </div>\n      </div>\n    </>\n  );\n}\n","type":"registry:component","target":"components/viberdy/share-button-expand.tsx"}],"meta":{"tier":"free","tags":["share","button","expand","social","copy-link","clipboard","spring"],"href":"https://viberdy.dev/library/share-button-expand","aiPrompt":"Create a single-file React + Tailwind component named ShareButtonExpand (a \"use client\" file, React only: no framer-motion, no icon library; draw icons as inline SVG, 24px viewBox, stroke 1.7, round caps and joins). Export the types ShareTarget (\"x\" | \"linkedin\" | \"email\" | \"copy\") and ShareButtonExpandProps.\n\nProps (all optional): url (default: window.location.href, read with useSyncExternalStore so SSR renders \"\"); title \"\"; text \"\"; targets [\"x\",\"email\",\"copy\"] (hoisted constant; \"linkedin\" only via the prop); native true (add a \"More options\" button when navigator.share exists); defaultOpen false; tone \"auto\" | \"light\" | \"dark\" (default \"auto\"); accent \"#ef4444\" (validated with a colour regex, else the default); onOpenChange(open); onShare(target) (for \"copy\" only after a successful copy); className on the root.\n\nLayout: everything is sized in em so a className like text-[26px] scales the whole piece. Root: relative inline-flex. A pill (padding .25em, 1px border, rounded-full) holds a 2.5em round trigger and a clipping box that holds the options. Tones: auto inherits currentColor (text 62%, border 17%, fill 4% via color-mix, no shadow) so it works on light and dark pages; light paints #fff with #e5e5e5 border and a soft shadow, icons #6b6b6b; dark paints #0d0e11 with rgba(255,255,255,.12) border. Hover, lens and focus use the accent.\n\nTrigger: aria-expanded, aria-controls, label \"Share\" / \"Close share options\". A share glyph (three nodes joined by two lines) rotates 90deg and shrinks to .4 while an X glyph rotates in from -90deg, 420ms cubic-bezier(.34,1.56,.64,1). Pressing any button scales its face to .88 over 180ms.\n\nOptions (a role=\"group\" labelled \"Share options\"): X and LinkedIn are text monograms (\"X\", \"in\", weight 700), email is an envelope, copy is a chain that swaps for a check, native is an arrow out of a tray. Never use real brand logos. X, LinkedIn and email are real anchors: x.com/intent/post?text=&url=, linkedin.com/sharing/share-offsite/?url=, mailto:?subject=&body= with every value passed through encodeURIComponent; web ones use target=\"_blank\" rel=\"noopener noreferrer\". Copy and native are buttons.\n\nMotion: the clip box animates width between 0 and the measured track width (offsetWidth, layout pixels, a ResizeObserver keeps it fitted) in 560ms cubic-bezier(.34,1.56,.64,1), so it overshoots a few pixels and settles; it is inert while closed. Each option enters with translateX(-.6em) scale(.5) blur(4px) to rest, 500ms the same spring, opacity 240ms, staggered 48ms from a 60ms delay; closing is 220ms staggered in reverse at 28ms. A lens (accent 15% fill with an inset accent 28% ring) slides to the hovered or focused option (translateX of offsetLeft, 340ms spring, width 340ms) and fades out when the pointer or focus leaves. A radial accent glow (9em, 20%) follows the pointer across the pill.\n\nCaption: a pill under the pill (absolute, top 100%, mt .75em, .75em text) shows the hovered or focused option's hint (\"Post on X\", \"Share on LinkedIn\", \"Send by email\", \"Copy link\"). Copy really copies: navigator.clipboard.writeText, falling back to a hidden textarea and execCommand, restoring focus. Only on success does the chain swap for a check (stroke draw 400ms) and the caption read \"Link copied\" for 1.9s in a polite role=\"status\"; on failure it reads \"Couldn't copy\" in red and nothing else changes. Native share calls navigator.share({title,text,url}) and ignores a dismissed sheet.\n\nBehaviour: click the trigger toggles; Escape closes and returns focus to the trigger; a pointerdown outside closes; ArrowLeft/Right/Home/End move focus across the trigger and options; using X, LinkedIn or email closes the menu. Focus rings are 2px accent outlines with 2px offset set on the element's own class (they must beat a global :focus-visible rule). All styles live in one static CSS string in a <style> element rendered beside the root, with no interpolated props; the accent goes in as a --sbx-accent custom property. prefers-reduced-motion: no width/lens/caption transitions, options only fade (150ms), icons swap by opacity. Touch targets are 2.5em (40px at the 16px default).","license":"https://viberdy.dev/license"}}