Skip to content
Haze UI

Typography (prose)

Wrapper that styles slotted long-form HTML (headings, lists, quotes, code, tables, figures) in the Haze type scale at 65 characters.

pnpm dlx shadcn@latest add @haze/typography
Open preview in a new tab
Liveno JavaScript

When to use

  • Rendering an article, doc page or changelog body from Markdown or a CMS as plain HTML
  • Slotted markup you do not control, where classes cannot go on each element
  • A narrow column that must wrap text, scroll wide code and tables inside themselves, and never widen the page

When not to use

  • A title with an eyebrow and intro above a section; use section-heading
  • Editing the content in the page; use rich-text-editor
  • Markup you write yourself with a few elements; classes on the elements are simpler

Installation

Add the Haze registry to components.json once, then install Typography (prose) with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/typography
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
size"sm" | "base""base"Body size: 13 px or 15 px. Headings, code and table text scale with it.
measurebooleantrueCaps the width at 65ch. Pass false when the parent column already sets the width.
leadbooleanfalseSets the first paragraph larger and muted, as an introduction.
classstring–Extra classes on the wrapper, merged with tailwind-merge.
...attributesHTML div attributes–Passed to the wrapper: id, lang, aria-labelledby, data attributes.

Accessibility

  • It only styles; the semantics come from the HTML you slot. Keep one heading level step at a time (h2, then h3) so the outline stays valid.
  • Quotes are marked by indentation, italics and muted text, not by a colored stripe, so they hold up in high-contrast modes.
  • Links are underlined and keep a visible focus outline, so they do not depend on color to be found.
  • Code blocks and tables scroll inside their own box (overflow-x-auto), which keeps the page from scrolling sideways at 320 px; the scrolling box is reachable by keyboard when it overflows, so give a wide pre role="region", tabindex="0" and an aria-label. Tables are styled as scroll boxes with display: block, which can drop table semantics in Safari with VoiceOver, so wrap a wide table in a focusable role="region" container with an aria-label and let that container scroll.
  • Headings carry scroll-margin so anchor links do not land under a sticky header.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Typography (prose)" with `npx shadcn@latest add @haze/typography`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import Typography from "@/components/haze/ui/typography.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/typography.md

  • Customize with real content

    Adapt the Haze typography ui for our product. Replace the demo values of these props with our real content: size, measure, lead, class, ...attributes. Keep the layout, the heading level rules and these accessibility details: It only styles; the semantics come from the HTML you slot. Keep one heading level step at a time (h2, then h3) so the outline stays valid. Quotes are marked by indentation, italics and muted text, not by a colored stripe, so they hold up in high-contrast modes. Links are underlined and keep a visible focus outline, so they do not depend on color to be found. Code blocks and tables scroll inside their own box (overflow-x-auto), which keeps the page from scrolling sideways at 320 px; the scrolling box is reachable by keyboard when it overflows, so give a wide pre role="region", tabindex="0" and an aria-label. Tables are styled as scroll boxes with display: block, which can drop table semantics in Safari with VoiceOver, so wrap a wide table in a focusable role="region" container with an aria-label and let that container scroll. Headings carry scroll-margin so anchor links do not land under a sticky header. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using typography, check it fits: use it when rendering an article, doc page or changelog body from markdown or a cms as plain html; slotted markup you do not control, where classes cannot go on each element; a narrow column that must wrap text, scroll wide code and tables inside themselves, and never widen the page. Avoid it when a title with an eyebrow and intro above a section; use section-heading; editing the content in the page; use rich-text-editor; markup you write yourself with a few elements; classes on the elements are simpler. Alternatives: @haze/section-heading, @haze/rich-text-editor.

Dependencies

  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog