antlitz
Menu

Typeset

A stylesheet for long-form content — markdown, MDX, a CMS rich-text field.

The components in this package cover authored markup, where you control the JSX. Typeset covers the other half: content rendered from data, where every node arrives as a plain element and there is nothing to wrap.

Installation

Import it after the theme, then wrap the rendered output.

@import "tailwindcss";
@import "antlitz/theme.css";
@import "antlitz/typeset.css";
<div className="typeset">{renderedContent}</div>

Usage

Setting long-form content

Typeset styles content rendered from data, where every node arrives as a plain element and there is nothing to wrap in a component.

  • Headings mirror the Heading component’s scale
  • Space between blocks scales with each block’s own size
    • Nested lists sit closer than separate blocks

A quotation, set off by a rule on the inline start edge.

Inline code, a link, and a ⌘K key.

export function Document() {
  return (
    <div className="typeset w-full max-w-lg">
      <h2>Setting long-form content</h2>
      <p>
        Typeset styles content rendered from data, where every node arrives as a
        plain element and there is nothing to wrap in a component.
      </p>
      <ul>
        <li>Headings mirror the Heading component’s scale</li>
        <li>
          Space between blocks scales with each block’s own size
          <ul>
            <li>Nested lists sit closer than separate blocks</li>
          </ul>
        </li>
      </ul>
      <blockquote>
        <p>A quotation, set off by a rule on the inline start edge.</p>
      </blockquote>
      <p>
        Inline <code>code</code>, a <a href="#typeset">link</a>, and a{" "}
        <kbd>⌘K</kbd> key.
      </p>
    </div>
  );
}

Headings map onto the Heading component's scale — h1 through h4 become lg through xs — so a rendered <h2> and an authored <Heading size="md"> are the same size on the same page.

Rhythm

Three variables set the reading rhythm; everything else derives from the theme's tokens.

| Variable | Default | Role | | ------------------- | ------------------- | -------------------- | | --typeset-size | --text-base | Base text size | | --typeset-leading | --leading-relaxed | Line height | | --typeset-flow | 1.5em | Space between blocks |

--typeset-flow is in em, so it resolves against each block's own size: a heading opens more room above itself than a paragraph does, from one declaration rather than a table of margins.

Spacing only ever comes from the start edge — a block is spaced by what precedes it, never by what follows — so appending to streamed content never restyles what is already on screen.

Overriding

Typeset sits in the components cascade layer with every element selector wrapped in :where(), so its specificity is exactly .typeset. Any Tailwind utility beats it without !important.

<div className="typeset [&_blockquote]:border-s-4">

To change the rhythm instead, set the variables.

<div className="typeset [--typeset-flow:1.25em]">

Opting out

Styled by Typeset.

Opted out — this paragraph keeps the browser’s defaults.

export function OptOut() {
  return (
    <div className="typeset w-full max-w-lg">
      <p>Styled by Typeset.</p>
      <div className="not-typeset flex flex-col gap-2">
        <p>Opted out — this paragraph keeps the browser’s defaults.</p>
        <Button size="sm" className="w-fit">
          Components keep their own styling
        </Button>
      </div>
    </div>
  );
}

not-typeset — or data-not-typeset — reverts everything Typeset applied within a subtree, so components rendered inside prose keep their own styling.

It uses revert-layer, which undoes the components layer and leaves later layers intact. Utilities still apply. A consumer's own @layer components rules are reverted there too, which is worth knowing if you keep raw component CSS in that layer.

Not a component

Typeset has no props and no import from the package root. It is a stylesheet you apply with a class, which is why it can style markup generated by a renderer you do not control.

The boundary: Typeset owns anything purely typographic; components exist where there is behaviour or an API worth having.