{
  "name": "typeset",
  "type": "registry:ui",
  "framework": "react",
  "title": "Typeset",
  "description": "Styles the HTML a markdown renderer emits — CommonMark and GFM — with three variables: size, leading and flow.",
  "dependencies": [
    "class-variance-authority"
  ],
  "files": [
    {
      "path": "ui/typeset.tsx",
      "content": "import { cva, type VariantProps } from \"class-variance-authority\"\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/*\n * Typeset is a wrapper and two class names — the rules live in the stylesheet\n * `add typeset` appended, keyed on `.typeset`. Nothing inside needs a class of\n * its own, which is the point: what goes in is whatever a markdown renderer\n * emitted, and it comes out with the library's rhythm.\n */\nconst typesetVariants = cva(\"typeset\", {\n  variants: {\n    preset: {\n      docs: \"typeset-docs\",\n      chat: \"typeset-chat\",\n      article: \"typeset-article\",\n    },\n    measure: {\n      true: \"typeset-measure\",\n      false: \"\",\n    },\n  },\n  defaultVariants: {\n    preset: \"docs\",\n    measure: false,\n  },\n})\n\nexport interface TypesetProps\n  extends\n    React.HTMLAttributes<HTMLDivElement>,\n    VariantProps<typeof typesetVariants> {\n  /** Render as `<article>` or any other element that suits the content. */\n  readonly as?: \"div\" | \"article\" | \"section\"\n}\n\nconst Typeset = React.forwardRef<HTMLDivElement, TypesetProps>(\n  ({ className, preset, measure, as: Component = \"div\", ...props }, ref) => (\n    <Component\n      ref={ref}\n      className={cn(typesetVariants({ preset, measure }), className)}\n      {...props}\n    />\n  )\n)\nTypeset.displayName = \"Typeset\"\n\nexport { Typeset, typesetVariants }\n",
      "type": "registry:ui"
    }
  ],
  "css": {
    "@layer components": "/* newt-ui · Typeset */\n\n/*\n * Typeset styles the HTML a general markdown renderer emits — CommonMark and\n * GitHub-flavoured markdown through remark, markdown-it, marked, MDX or a CMS —\n * with three variables rather than a rule per element:\n *\n *   --typeset-size     the base font size everything else is an `em` of\n *   --typeset-leading  the line height\n *   --typeset-flow     the space between block children\n *\n * Everything else resolves to a --newt-* token, so a typeset block follows the\n * palette, the light surfaces and a preset without knowing they exist.\n *\n * A chat message written in chat markdown — mentions, timestamps, spoilers —\n * is not this stylesheet's job: the Markdown component parses that source and\n * renders it with the library's own parts.\n */\n\n.typeset {\n  --typeset-size: 1em;\n  --typeset-leading: 1.75;\n  --typeset-flow: 1.25em;\n  --typeset-font-body: var(--newt-font-sans);\n  --typeset-font-heading: var(--newt-font-display);\n  --typeset-font-mono: var(--newt-font-mono);\n\n  font-family: var(--typeset-font-body);\n  font-size: var(--typeset-size);\n  line-height: var(--typeset-leading);\n  color: var(--newt-text-secondary);\n  text-wrap: pretty;\n}\n\n/*\n * One rule owns the rhythm: every block child carries the same trailing space\n * and nothing carries a leading one, so a block's spacing never depends on\n * what happens to precede it.\n *\n * Quotes and list items hold blocks of their own — a multi-line quote is\n * several paragraphs, not one — so they keep the same rhythm inside rather\n * than falling back to the browser's margins.\n */\n.typeset > :where(*),\n.typeset :where(blockquote, li) > :where(*) {\n  margin-block: 0 var(--typeset-flow);\n}\n\n.typeset > :where(*:last-child),\n.typeset :where(blockquote, li) > :where(*:last-child) {\n  margin-block-end: 0;\n}\n\n.typeset :where(h1, h2, h3, h4, h5, h6) {\n  font-family: var(--typeset-font-heading);\n  font-weight: 700;\n  line-height: 1.25;\n  color: var(--newt-text-primary);\n  text-wrap: balance;\n}\n\n.typeset > :where(h1, h2, h3, h4, h5, h6) {\n  margin-block-start: calc(var(--typeset-flow) * 1.6);\n}\n\n.typeset > :where(:first-child) {\n  margin-block-start: 0;\n}\n\n/* A heading and the paragraph under it are one unit, not two. */\n.typeset :where(h1, h2, h3, h4, h5, h6) + :where(*) {\n  margin-block-start: 0;\n}\n\n.typeset :where(h1) {\n  font-size: 2em;\n  letter-spacing: -0.02em;\n}\n.typeset :where(h2) {\n  font-size: 1.5em;\n  letter-spacing: -0.015em;\n}\n.typeset :where(h3) {\n  font-size: 1.25em;\n}\n.typeset :where(h4) {\n  font-size: 1.125em;\n}\n.typeset :where(h5, h6) {\n  font-size: 1em;\n}\n\n.typeset :where(strong) {\n  font-weight: 600;\n  color: var(--newt-text-primary);\n}\n\n/*\n * The rest of the inline set. Emphasis and strikethrough would inherit the\n * browser's defaults, but they are stated here so the offset under an\n * underline — raw `<u>` is valid in markdown — is the one the links use rather\n * than the one the font happens to suggest.\n */\n.typeset :where(em) {\n  font-style: italic;\n}\n\n.typeset :where(u) {\n  text-decoration: underline;\n  text-underline-offset: 3px;\n}\n\n.typeset :where(s, del) {\n  text-decoration: line-through;\n  color: var(--newt-text-muted);\n}\n\n/*\n * Fine print. Smaller and quieter, and `em` so it shrinks against whatever it\n * sits in rather than against the root.\n */\n.typeset :where(small) {\n  font-size: 0.8125em;\n  color: var(--newt-text-muted);\n}\n\n/* Highlighted text: the brand hue, thinned so the words stay readable on it. */\n.typeset :where(mark) {\n  padding-inline: 0.15em;\n  border-radius: var(--newt-radius-sm);\n  background: color-mix(in oklab, var(--newt-brand) 30%, transparent);\n  color: var(--newt-text-primary);\n}\n\n/* A footnote reference must not push its line away from the one above. */\n.typeset :where(sup, sub) {\n  font-size: 0.75em;\n  line-height: 0;\n}\n\n.typeset :where(a) {\n  color: var(--newt-text-link);\n  text-decoration: underline;\n  text-underline-offset: 3px;\n}\n\n.typeset :where(a:hover) {\n  text-decoration-thickness: 2px;\n}\n\n.typeset :where(ul, ol) {\n  padding-inline-start: 1.5em;\n}\n\n.typeset :where(ul) {\n  list-style: disc;\n}\n\n.typeset :where(ol) {\n  list-style: decimal;\n}\n\n.typeset :where(li) {\n  margin-block-end: calc(var(--typeset-flow) * 0.35);\n}\n\n.typeset :where(li)::marker {\n  color: var(--newt-text-muted);\n}\n\n/*\n * GFM task lists: the renderer puts a checkbox first in the item, or first in\n * the item's paragraph when the list is loose. The box takes the bullet's\n * place in the indent, so the text lines up with the items around it.\n */\n.typeset\n  :where(\n    li:has(\n      > input[type=\"checkbox\"]:first-child,\n      > p:first-child > input[type=\"checkbox\"]:first-child\n    )\n  ) {\n  list-style: none;\n}\n\n.typeset :where(li input[type=\"checkbox\"]:first-child) {\n  margin-block: 0;\n  margin-inline: -1.35em 0.5em;\n  vertical-align: -0.1em;\n  accent-color: var(--newt-brand);\n}\n\n/* A nested list belongs to its item, so it does not restate the block gap. */\n.typeset :where(li > ul, li > ol) {\n  margin-block: calc(var(--typeset-flow) * 0.35);\n}\n\n.typeset :where(blockquote) {\n  margin-inline: 0;\n  padding-inline-start: 1em;\n  border-inline-start: 4px solid var(--newt-border);\n  color: var(--newt-text-muted);\n}\n\n.typeset :where(hr) {\n  border: 0;\n  border-block-start: 1px solid var(--newt-border);\n}\n\n.typeset :where(code) {\n  padding: 0.15em 0.35em;\n  border-radius: var(--newt-radius-sm);\n  background: var(--newt-bg-surface);\n  font-family: var(--typeset-font-mono);\n  font-size: 0.875em;\n  color: var(--newt-text-primary);\n}\n\n.typeset :where(pre) {\n  padding: 1em 1.15em;\n  overflow-x: auto;\n  border: 1px solid var(--newt-border);\n  border-radius: var(--newt-radius-md);\n  background: var(--newt-bg-base);\n  font-family: var(--typeset-font-mono);\n  font-size: 0.875em;\n  line-height: 1.6;\n}\n\n.typeset :where(pre code) {\n  padding: 0;\n  border-radius: 0;\n  background: none;\n  font-size: inherit;\n}\n\n.typeset :where(kbd) {\n  padding: 0.1em 0.4em;\n  border: 1px solid var(--newt-border);\n  border-radius: var(--newt-radius-sm);\n  font-family: var(--typeset-font-mono);\n  font-size: 0.8em;\n}\n\n/* Definition lists: the term reads as a label, the description hangs under it. */\n.typeset :where(dt) {\n  font-weight: 600;\n  color: var(--newt-text-primary);\n}\n\n.typeset :where(dd) {\n  margin-inline-start: 1.5em;\n}\n\n.typeset :where(dd + dt) {\n  margin-block-start: calc(var(--typeset-flow) * 0.5);\n}\n\n/* A disclosure: the summary is the control, so it says so. */\n.typeset :where(summary) {\n  cursor: pointer;\n  font-weight: 600;\n  color: var(--newt-text-primary);\n}\n\n.typeset :where(details[open] > summary) {\n  margin-block-end: calc(var(--typeset-flow) * 0.5);\n}\n\n.typeset :where(figure) {\n  margin-inline: 0;\n}\n\n.typeset :where(figcaption) {\n  margin-block-start: 0.5em;\n  font-size: 0.875em;\n  color: var(--newt-text-muted);\n}\n\n.typeset :where(img, video) {\n  max-inline-size: 100%;\n  height: auto;\n  border-radius: var(--newt-radius-md);\n}\n\n.typeset :where(table) {\n  inline-size: 100%;\n  border-collapse: collapse;\n  font-size: 0.9375em;\n}\n\n.typeset :where(th, td) {\n  padding: 0.5em 0.7em;\n  border-block-end: 1px solid var(--newt-border);\n  vertical-align: top;\n}\n\n/*\n * A GFM column written `:-:` or `--:` arrives as `align` on its cells. That\n * attribute loses to any author rule, so `start` only applies where none was\n * asked for.\n */\n.typeset :where(th:not([align]), td:not([align])) {\n  text-align: start;\n}\n\n.typeset :where(th) {\n  color: var(--newt-text-primary);\n  font-weight: 600;\n}\n\n/*\n * A table is the one element that cannot reflow: below the narrow breakpoint\n * it scrolls sideways inside its own box rather than widening the page.\n */\n@media (max-width: 40rem) {\n  .typeset > :where(table) {\n    display: block;\n    overflow-x: auto;\n    white-space: nowrap;\n  }\n}\n\n/*\n * Footnotes, as GFM renderers emit them: a section at the end of the body,\n * set apart and a step quieter than the text that cites them.\n */\n.typeset > :where([data-footnotes], .footnotes) {\n  padding-block-start: var(--typeset-flow);\n  border-block-start: 1px solid var(--newt-border);\n  font-size: 0.875em;\n  color: var(--newt-text-muted);\n}\n\n/* --- presets ------------------------------------------------------------ */\n\n/* Long-form reading: the defaults, stated so a preset is always explicit. */\n.typeset-docs {\n  --typeset-size: 1em;\n  --typeset-leading: 1.75;\n  --typeset-flow: 1.25em;\n}\n\n/*\n * Conversation: tighter, because the turn is the unit and it is short — an\n * assistant reply, a comment thread, a support transcript.\n */\n.typeset-chat {\n  --typeset-size: 0.9375em;\n  --typeset-leading: 1.375;\n  --typeset-flow: 0.5em;\n}\n\n/* Editorial: larger and airier, for text somebody sat down to read. */\n.typeset-article {\n  --typeset-size: 1.0625em;\n  --typeset-leading: 1.8;\n  --typeset-flow: 1.5em;\n}\n\n/* Line length is a property of the column, not of the type. */\n.typeset-measure {\n  max-inline-size: 68ch;\n}\n\n/* --- opting out --------------------------------------------------------- */\n\n/*\n * An island of interface inside a body of prose — a component, an embed, a\n * table of controls — should not inherit the rhythm. Marking it takes it back\n * out, including everything inside it.\n */\n.typeset :where(.not-typeset, .not-typeset *) {\n  margin-block: revert;\n  font-family: revert;\n  font-size: revert;\n  line-height: revert;\n  color: revert;\n}"
  }
}