Skip to content

Typeset

One stylesheet for rendered text, from documentation to streaming agent replies, set in the Silkware theme through three presets.

Rendered text is HTML nobody wrote classes for: Markdown from an agent, an article from a CMS, the body of a documentation page. Silkware styles all of it with shadcn/typeset, one CSS file that styles everything inside a typeset container. Colours, fonts and radius come from the theme, so the text follows a rebrand and dark mode without its own palette. Three Silkware presets set the reading rhythm for documentation and articles, chat, and compact surfaces.

How it works

Typeset is one file next to app/globals.css, imported right after Tailwind:

@import "tailwindcss";@import "tw-animate-css";@import "shadcn/tailwind.css";@import "./typeset.css";
  • app/typeset.css is upstream's file, unchanged except that its explanatory comments were removed. It styles headings, paragraphs, links, lists, task lists, inline code, code blocks, quotes, rules, tables, footnotes, figures and keyboard keys inside a typeset container.
  • app/globals.css holds the Silkware presets: three small classes that set Typeset's variables from tokens in :root. A rebrand changes them in the theme file, and the theme editor lists them under Rendered text.

Wrap the rendered text in typeset and a preset:

<article className="typeset typeset-docs">{content}</article>

typeset turns the styles on; the preset sets the rhythm. Everything else is derived from three values:

VariableWhat it sets
--typeset-sizeThe base text size. 1em follows the surrounding layout. Below 768px Typeset sets the text 12.5% larger.
--typeset-leadingThe line height.
--typeset-flowThe space between blocks. Headings, lists, tables and rules derive their spacing from it.

Text is set in the theme's foreground on the theme's fonts: running text inherits Mona Sans from the page, headings read --font-heading, code reads --font-mono. Notes such as list markers and captions use --muted-foreground, rules use --border, and code backgrounds use --muted.

Presets

PresetSizeLeadingFlowUse it for
typeset-docs16px at every width1.651.25emDocumentation, articles, help pages, release notes
typeset-chatFollows the message1.651emAgent replies and any Markdown in a conversation
typeset-compactFollows the container1.450.75emRendered text inside a card, a dialog, a popover or a table cell

The values come from the brand's type rules: running text is 16px on a 1.65 line, full ink, with grey only for notes. typeset-docs cancels Typeset's 12.5% step up on phones, because the brand keeps running text at 16px on every screen. The chat and compact presets keep the step, so a 14px message reads at 15.75px on a phone.

Each value is a token in :root:

TokenValuePreset
--typeset-docs-size1remtypeset-docs
--typeset-docs-leading1.65typeset-docs
--typeset-docs-flow1.25emtypeset-docs
--typeset-chat-leading1.65typeset-chat
--typeset-chat-flow1emtypeset-chat
--typeset-compact-leading1.45typeset-compact
--typeset-compact-flow0.75emtypeset-compact

Documentation and articles

typeset-docs sets the body of every page on this site. Headings are 600, running text 400 and links 500 with an underline. Give an article a measure of 45 to 75 characters with the layout, for example max-w-prose; Typeset never sets a width.

Receive a steel delivery

Ferrolva Acciai delivers steel bar to the Bergamo plant on Fridays. Check each lot against PO-2418 before the bar goes to the rack, and record the weight in the ERP.

  1. Scan the label on the bundle.
  2. Compare the lot number with the order.
  3. Send any difference to Giulia, head of purchasing.

Tolerances

PartLotWeight
BR-200177451,240 kg
BR-20027746980 kg

A delivery that fails the check stays in receiving until Marco signs it off.

Chat

typeset-chat tightens the space between blocks so a reply reads as one turn. The Markdown component applies typeset typeset-chat to its own root, so an agent reply needs no wrapper. The text takes its size from the message around it.

Which purchase orders wait for approval?

Two orders wait for Giulia:

  • PO-2418, steel bar from Ferrolva Acciai, due Friday.
  • PO-2419, fasteners from Bullovia, due next week.

Both match the quotes. Approve them in Purchasing, under Waiting on you.

Compact

typeset-compact is for text that sits inside a component: an agent's summary on a card, the body of a dialog, a note in a popover. The leading drops to 1.45 and the blocks sit closer together.

Agent summary
Receiving, Bergamo plant

Lot 7745 arrived complete. The agent matched it to PO-2418 and found one difference:

  • Bundle 3 weighs 12 kg under the delivery note.
  • Marco is reviewing it as NC-44.

Use it

Documentation

Every page under /docs renders its MDX body inside typeset typeset-docs. Live previews and do and don't pairs sit between the prose containers rather than inside them, so an example that carries its own typeset container renders exactly as it does in your application.

Articles and CMS content

Wrap the HTML the renderer returns:

<article className="typeset typeset-docs max-w-prose">  <div dangerouslySetInnerHTML={{ __html: html }} /></article>

Sanitise HTML from a CMS before you render it; Typeset styles markup, it does not clean it.

Agent replies

Use the Markdown component. It renders with Streamdown, which keeps unfinished Markdown readable while a reply streams, and sends fenced code to Code Block.

import { Markdown } from "@/components/markdown"
<Message>  <MessageContent>    <Markdown>{text}</Markdown>  </MessageContent></Message>

To set a reply in another preset, pass it as a class: <Markdown className="typeset-compact">. Streamdown's own Tailwind classes on headings, lists, tables, quotes and rules are replaced with plain elements, so Typeset alone sets them. Links keep Streamdown's link check, which asks before an external page opens.

Components inside the text

Anything with a data-slot attribute, which is every Silkware component, keeps its own styles inside a typeset container, and a component placed directly in the flow gets the same space above as a paragraph. To keep anything else out, add not-typeset or data-not-typeset:

<div className="typeset typeset-docs">  <p>Styled text.</p>  <figure className="not-typeset">A chart with its own caption.</figure></div>

The opt-out covers everything inside it, including another typeset container. A wide table wraps to fit; to scroll it instead, wrap it in typeset-scroll.

Install

The theme brings Typeset with it. To add it on its own:

pnpm dlx shadcn@latest add @silkware/typeset

The item writes app/typeset.css and adds its import to your main CSS file. The presets are part of the theme: without the Silkware globals.css, a typeset container uses upstream's defaults.

Make a preset

To change one of the three Silkware presets, change its token in :root or in the theme editor. To add a preset, write a class that sets one or more of the three variables. Put it in app/globals.css beside the Silkware presets, inside @layer components, so a utility on the container still wins:

@layer components {  .typeset-release-notes {    --typeset-leading: 1.55;    --typeset-flow: 1em;  }}
<section className="typeset typeset-release-notes">{notes}</section>

For a single change, set the variable on the container instead: typeset [--typeset-flow:1.5em]. Change fonts with --typeset-font-body, --typeset-font-heading and --typeset-font-mono, and only to another theme token; the brand sets everything in Mona Sans.

Accessibility and dark mode

  • Sizes are relative, so text follows the browser's font size and zoom.
  • Colours are theme tokens, so dark mode and a data-theme="dark" region need nothing extra. Running text stays in --foreground, which holds 4.5:1 in both modes.
  • Links are underlined, not only coloured, and show a 2px focus outline in --ring.
  • In forced colours, inline code keeps a border where its background disappears.
  • Earlier blocks never change when a new block streams in: spacing is set above each block only, and nothing depends on what comes after it. Screen readers and the reader's eye stay where they were.
  • For readers who want more room, a preset with a larger size and leading is enough: --typeset-size: 1.125rem and --typeset-leading: 1.8.

What it does not do

  • It does not set a width. The layout sets the measure.
  • It does not style components. Buttons, code blocks, tables built with Table and every other Silkware component keep their own look.
  • It does not follow every brand rule. Headings use Typeset's scale, from 1.75em for H1 to 0.8125em for H6, not the brand's display steps; links are 500, where the brand sets text links at 600; inline code is 0.85em, which falls below 13px in a 14px message on a desktop. These come from the upstream file and are recorded as decisions.
  • It does not sanitise HTML, highlight code or load fonts.

Guidelines

Delivery check

Compare the lot number with the order before the bar goes to the rack.

Do

Wrap rendered text in a typeset container with a preset, and let the preset set size and spacing.

Delivery check

Compare the lot number with the order before the bar goes to the rack.

Don’t

Don’t give each heading and paragraph its own size and margin classes. They drift from every other page.