{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "typography-prose",
  "title": "Typography Prose",
  "description": "Readable styles for rich text from Markdown or a CMS, without a plugin: balanced headings with hover # links, comfortable line length and rhythm, lists, quotes, inline code, code blocks with a Copy button, tables, marks and keys, scoped so they never leak into the rest of the page.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/typography-prose/typography-prose.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 TypographyProseProps {\n  /** Rich content: your own elements, or use html for a string (from Markdown or a CMS). */\n  children?: React.ReactNode;\n  html?: string;\n  size?: \"sm\" | \"base\" | \"lg\";\n  /** Line length cap, e.g. \"68ch\". */\n  measure?: string;\n  /** Give h2 / h3 ids and a # link that appears on hover. */\n  anchors?: boolean;\n  /** Put a Copy button on code blocks. */\n  copyCode?: boolean;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { text: \"rgba(245,244,241,0.78)\", strong: \"#F5F4F1\", muted: \"rgba(245,244,241,0.5)\", line: \"rgba(255,255,255,0.1)\", code: \"rgba(255,255,255,0.07)\", pre: \"#111111\", link: \"#F5F4F1\", mark: \"rgba(255,122,107,0.3)\", accent: \"#FF7A6B\" },\n  light: { text: \"rgba(10,10,10,0.78)\", strong: \"#0A0A0A\", muted: \"rgba(10,10,10,0.5)\", line: \"rgba(10,10,10,0.1)\", code: \"rgba(10,10,10,0.06)\", pre: \"#F6F6F4\", link: \"#0A0A0A\", mark: \"rgba(255,122,107,0.3)\", accent: \"#E5484D\" },\n};\n\nconst SIZES = { sm: 14.5, base: 16.5, lg: 18.5 };\n\nconst slug = (t: string) =>\n  t\n    .toLowerCase()\n    .trim()\n    .replace(/[^\\w\\s-]/g, \"\")\n    .replace(/\\s+/g, \"-\")\n    .slice(0, 60);\n\nfunction css(scope: string, p: (typeof PALETTES)[\"dark\"], fs: number, measure: string) {\n  const s = `[data-prose=\"${scope}\"]`;\n  return `\n${s}{color:${p.text};font-size:${fs}px;line-height:1.7;max-width:${measure};font-family:Inter,ui-sans-serif,system-ui,sans-serif}\n${s}>*+*{margin-top:1.15em}\n${s} :where(h1,h2,h3,h4){color:${p.strong};font-weight:650;letter-spacing:-0.02em;line-height:1.2;text-wrap:balance;scroll-margin-top:80px;position:relative}\n${s} h1{font-size:2.15em;margin-top:0}\n${s} h2{font-size:1.5em;margin-top:2em}\n${s} h3{font-size:1.2em;margin-top:1.6em}\n${s} :where(h2,h3)+*{margin-top:0.6em}\n${s} p{text-wrap:pretty}\n${s} strong{color:${p.strong};font-weight:600}\n${s} a{color:${p.link};text-decoration:underline;text-decoration-color:${p.line};text-underline-offset:0.2em;text-decoration-thickness:1.5px;transition:text-decoration-color .2s}\n${s} a:hover{text-decoration-color:${p.link}}\n${s} :where(ul,ol){padding-left:1.4em}\n${s} ul{list-style:disc}\n${s} ol{list-style:decimal}\n${s} li{margin-top:0.4em;padding-left:0.2em}\n${s} ul>li::marker{color:${p.muted}}\n${s} ol>li::marker{color:${p.muted};font-variant-numeric:tabular-nums}\n${s} blockquote{margin-left:0;padding-left:1.1em;border-left:3px solid ${p.accent};color:${p.strong};font-style:normal;font-size:1.08em}\n${s} :not(pre)>code{background:${p.code};color:${p.strong};padding:0.15em 0.4em;border-radius:6px;font-size:0.86em;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}\n${s} pre{position:relative;background:${p.pre};border:1px solid ${p.line};border-radius:14px;padding:1em 1.2em;overflow-x:auto;font-size:0.84em;line-height:1.65}\n${s} pre code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;color:${p.strong}}\n${s} mark{background:${p.mark};color:inherit;padding:0 0.15em;border-radius:3px}\n${s} kbd{font-family:inherit;font-size:0.8em;padding:0.1em 0.45em;border:1px solid ${p.line};border-bottom-width:2px;border-radius:6px;color:${p.strong}}\n${s} hr{border:0;border-top:1px solid ${p.line};margin:2.4em 0}\n${s} table{width:100%;border-collapse:collapse;font-size:0.92em}\n${s} th{color:${p.strong};font-weight:600;text-align:left;border-bottom:1px solid ${p.line};padding:0.6em 0.8em}\n${s} td{border-bottom:1px solid ${p.line};padding:0.6em 0.8em}\n${s} :where(img,figure){border-radius:14px;max-width:100%}\n${s} figcaption{color:${p.muted};font-size:0.85em;margin-top:0.6em;text-align:center}\n${s} .prose-anchor{position:absolute;left:-1em;opacity:0;color:${p.muted};text-decoration:none;transition:opacity .15s;font-weight:400}\n${s} :where(h2,h3):hover .prose-anchor,${s} .prose-anchor:focus{opacity:1}\n${s} .prose-copy{position:absolute;top:0.55em;right:0.55em;font:600 11.5px Inter,sans-serif;padding:0.35em 0.7em;border-radius:8px;border:1px solid ${p.line};background:${p.pre};color:${p.muted};cursor:pointer;opacity:0;transition:opacity .15s,color .15s}\n${s} pre:hover .prose-copy,${s} .prose-copy:focus-visible{opacity:1}\n${s} .prose-copy[data-done]{color:${p.strong}}\n`;\n}\n\nexport function TypographyProse({ children, html, size = \"base\", measure = \"68ch\", anchors = true, copyCode = true, theme = \"dark\", className }: TypographyProseProps) {\n  const p = PALETTES[theme];\n  const scope = React.useId().replace(/[^a-zA-Z0-9]/g, \"\");\n  const ref = React.useRef<HTMLDivElement>(null);\n\n  // Decorate the rendered content: heading ids + # links, and copy buttons on code blocks.\n  React.useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    const added: HTMLElement[] = [];\n    if (anchors) {\n      root.querySelectorAll<HTMLElement>(\"h2, h3\").forEach((h) => {\n        if (!h.id) h.id = slug(h.textContent ?? \"\");\n        if (h.querySelector(\".prose-anchor\")) return;\n        const a = document.createElement(\"a\");\n        a.href = `#${h.id}`;\n        a.className = \"prose-anchor\";\n        a.textContent = \"#\";\n        a.setAttribute(\"aria-label\", `Link to ${h.textContent}`);\n        h.prepend(a);\n        added.push(a);\n      });\n    }\n    if (copyCode) {\n      root.querySelectorAll<HTMLElement>(\"pre\").forEach((pre) => {\n        if (pre.querySelector(\".prose-copy\")) return;\n        const b = document.createElement(\"button\");\n        b.type = \"button\";\n        b.className = \"prose-copy\";\n        b.textContent = \"Copy\";\n        b.addEventListener(\"click\", async () => {\n          try {\n            await navigator.clipboard.writeText(pre.querySelector(\"code\")?.textContent ?? pre.textContent ?? \"\");\n          } catch {\n            // Clipboard blocked; still confirm so the button doesn't feel dead.\n          }\n          b.textContent = \"Copied\";\n          b.setAttribute(\"data-done\", \"\");\n          window.setTimeout(() => {\n            b.textContent = \"Copy\";\n            b.removeAttribute(\"data-done\");\n          }, 1400);\n        });\n        pre.appendChild(b);\n        added.push(b);\n      });\n    }\n    return () => added.forEach((el) => el.remove());\n  }, [anchors, copyCode, html, children]);\n\n  return (\n    <>\n      <style>{css(scope, p, SIZES[size], measure)}</style>\n      {html !== undefined ? (\n        <div ref={ref} data-prose={scope} className={cn(className)} dangerouslySetInnerHTML={{ __html: html }} />\n      ) : (\n        <div ref={ref} data-prose={scope} className={cn(className)}>\n          {children ?? <SampleArticle />}\n        </div>\n      )}\n    </>\n  );\n}\n\nfunction SampleArticle() {\n  return (\n    <>\n      <h1>Designing calm interfaces</h1>\n      <p>\n        Calm software does its job and gets out of the way. It shows what matters now, explains itself when asked, and never makes you <mark>hunt for the next step</mark>. Here are the habits we lean on.\n      </p>\n      <h2>Start from the content</h2>\n      <p>\n        Write the real words first, then design around them. Placeholder text hides problems: long names, empty states, <a href=\"#\">awkward translations</a>.\n      </p>\n      <ul>\n        <li>One primary action per screen</li>\n        <li>Plain labels over clever ones</li>\n        <li>\n          Shortcuts for power users, like <kbd>⌘</kbd> <kbd>K</kbd>\n        </li>\n      </ul>\n      <blockquote>Good design is as little design as possible.</blockquote>\n      <h2>Ship small, often</h2>\n      <p>\n        Keep changes small enough to review in one sitting. A tiny helper like <code>formatPrice()</code> is easier to trust than a new framework.\n      </p>\n      <pre>\n        <code>{`export function formatPrice(cents: number, currency = \"USD\") {\n  return new Intl.NumberFormat(\"en-US\", { style: \"currency\", currency }).format(cents / 100);\n}`}</code>\n      </pre>\n      <h3>What we measure</h3>\n      <table>\n        <thead>\n          <tr>\n            <th>Signal</th>\n            <th>Target</th>\n          </tr>\n        </thead>\n        <tbody>\n          <tr>\n            <td>Time to first action</td>\n            <td>&lt; 10 s</td>\n          </tr>\n          <tr>\n            <td>Support tickets per 1k users</td>\n            <td>&lt; 4</td>\n          </tr>\n        </tbody>\n      </table>\n    </>\n  );\n}\n\nexport default TypographyProse;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}