Typeset
Markdown and CMS HTML arrive unstyled: headings, paragraphs, lists, tables. You can chase sizes and spacing per surface - blog, docs, chat - or share one rhythm that follows Cubix theme tokens.
Cubix Typeset is that shared layer. Use semantic roles (text-headline, text-body) when the meaning is clear. Use the numeric scale (text-sm) for chrome. Wrap long-form HTML in typeset when you need measure, heading steps, and block rhythm. This docs site uses docs-prose as its preset.
Principles
Rhythm stays on five controls. Heading steps, list indent, optical tracking, and space under a title derive from them:
| Control | Role | Notes |
|---|---|---|
| --typeset-size | Base text size | Defaults to text-body (15px). Chat uses text-description (14px); docs stay on body. |
| --typeset-leading | Line height | 1.5 minimum for body. Typeset uses 1.6; docs prose uses 1.7. |
| --typeset-flow | Block spacing | Gap between paragraphs, lists, and other blocks. One-direction only. |
| --typeset-stack | Title to supporting line | Gap from a title to its supporting line. 0.125rem in every locale. |
| --typeset-measure | Line length | 65ch by default. Chat sets this to none so the parent owns width. |
- Readable by default - body sits at 15px with at least 1.5 line-height - a Persian-first optical scale so IRANSans does not feel oversized. Display type tracks tighter. On
[lang=fa], IRANSans XV uses a baseline-corrected face, 0 heading tracking, and tuned prose leading.text-label(13px) andtext-caption(12px) stay fixed for controls. - Fits the container - relative sizing follows surrounding UI; chat bubbles stay compact, articles can open up.
- Uses your theme - colors, radius, and fonts come from Cubix tokens. Dark mode flips with them.
- Owned CSS - presets live in your project so you can edit them without a plugin API.
- Streaming-friendly - prefer one-direction spacing so new blocks do not restyle earlier ones.
Font families
Cubix loads Geist for UI and headings, Geist Mono for code, and IRANSans XV for Persian. Variables are set on <html> via next/font.
| Token | Family | Usage |
|---|---|---|
| --font-sans | Geist - The quick brown fox jumps over the lazy dog. | UI text, body copy, and most interface chrome. |
| --font-heading | Geist - The quick brown fox jumps over the lazy dog. | Page titles and section headings via font-heading. |
| --font-mono | Geist Mono - The quick brown fox jumps over the lazy dog. | Code blocks, inline code, paths, and terminal snippets. |
| --font-iran-sans | IRANSans XV - طراحی سیستم تایپ کوبیکس برای محصول فارسی | Persian / RTL (variable, 100-900). Baseline-corrected via font metric overrides so fixed-height controls center like Latin; Latin stays on Geist. |
Type scale
Product UI uses the Tailwind-aligned scale from @theme in app/globals.css. Type tokens stay as live CSS variables so utilities always resolve the documented size. Prefer roles (text-label, text-caption) for meaning; use the numeric scale for chrome and one-offs. Pixel sizes assume a 16px root:
| Token | Size | Line height | Usage |
|---|---|---|---|
| text-xs | 0.75rem / 12px | calc(1 / 0.75) | Numeric twin of text-caption |
| text-13 | 0.8125rem / 13px | calc(1.125 / 0.8125) | Numeric twin of text-label |
| text-sm | 0.875rem / 14px | calc(1.25 / 0.875) | Numeric twin of text-description |
| text-base | 0.9375rem / 15px | calc(1.5 / 0.9375) | Numeric twin of text-body |
| text-lg | 1.0625rem / 17px | calc(1.625 / 1.0625) | Numeric twin of text-lead |
| text-xl | 1.25rem / 20px | calc(1.75 / 1.25) | Small headings |
| text-2xl | 1.375rem / 22px | calc(1.875 / 1.375) | Numeric twin of text-title |
| text-3xl | 1.75rem / 28px | calc(2.125 / 1.75) | Section headings |
| text-4xl | 2rem / 32px | calc(2.375 / 2) | Page titles |
| text-5xl | 2.75rem / 44px | 1.15 | Hero titles |
| text-6xl | 3.5rem / 56px | 1.12 | Marketing displays |
| text-7xl | 4.25rem / 68px | 1.1 | Large displays |
| text-8xl | 5.5rem / 88px | 1.08 | Poster-scale type |
Type roles
Prefer roles when the content has a job. Pair headings with font-heading. Display and headline are fluid from a 320px viewport to 1280px so marketing type scales without extra breakpoints. Caption, label, and description keep size and tracking; set weight with font-medium on controls.
Cubix primitives use these roles by default: text-label on field titles; text-caption on input hints, Badge, and Kbd; text-description on Button, Card copy, and dialog descriptions; text-body on Card and Dialog titles. Numeric utilities remain for code, charts, and one-off layout.
| Role | Size | Line height | Tracking | Weight | Usage |
|---|---|---|---|---|---|
| text-display | 32-52px | 1.12 | -0.03em | 600 | Hero and campaign titles |
| text-headline | 28-32px | 1.2 | -0.025em | 600 | Page titles |
| text-title | 22px | 1.364 | -0.02em | 600 | Section headings |
| text-lead | 17px | 1.529 | 0 | 400 | Intro paragraphs |
| text-body | 15px | 1.65 | 0 | 400 | Readable body copy |
| text-description | 14px | 1.429 | 0.005em | 400 | Supporting UI copy, chat typeset |
| text-label | 13px | 1.385 | 0.01em | 400 | Field titles and form labels |
| text-caption | 12px | 1.333 | 0.02em | 400 | Hints under inputs, badges, kbd, compact chrome |
Measure
Line length is a first-class token. Keep body copy near 65 characters. Shorter for asides, never much past 75:
| Token | Value | Usage |
|---|---|---|
| max-w-prose | 65ch | Ideal reading column (45-75ch). |
| max-w-prose-narrow | 45ch | Short asides, captions, callouts. |
| max-w-prose-wide | 75ch | Upper bound before lines get hard to scan. |
Optical tracking
Large type needs tighter letter-spacing; small labels need a little air. Persian and RTL headings reset tracking to 0 on [lang=fa]:
| Token | Value | Usage |
|---|---|---|
| tracking-display | -0.03em | Largest display type |
| tracking-headline | -0.025em | Page and section titles |
| tracking-title | -0.02em | Smaller headings |
| tracking-body | 0em | Body, lead, and UI copy |
| tracking-label | 0.02em | text-caption and compact overlines |
Persian
Locale metrics live in Typeset, not in each component. Set lang="fa" on a root or subtree. Utilities such as text-description read var(--text-description), so IRANSans XV, tuned prose leading, and heading flow all follow. Type sizes stay on the documented Persian-first scale (12 / 13 / 14 / 15 / 17 / 20 / 22 / 28 / 32px). Title-to-description stack stays the same as English.
Vertical centering is solved once, in the font face. Geist places its baseline exactly half a cap-height below the middle of a leading-none line box, which is why Latin labels look centered in fixed-height controls. IRANSans XV does not, so Cubix corrects it with ascent-override / descent-override on the @font-face itself. The total stays at 150%, so only the baseline moves - prose leading is unchanged, and no component needs per-button padding, a label wrapper, or a translate offset.
import localFont from "next/font/local";
// IRANSans XV ships ascent 100% / descent 50%, which leaves its baseline ~0.068em
// too high, so Persian reads about 1px high in leading-none controls. Moving the
// baseline down while keeping the 150% total leaves prose leading untouched.
export const iranSans = localFont({
src: "./IRANSansXV.woff2",
weight: "100 900",
variable: "--font-iran-sans",
display: "swap",
declarations: [
{ prop: "ascent-override", value: "107%" },
{ prop: "descent-override", value: "43%" },
{ prop: "line-gap-override", value: "0%" },
],
});[lang="fa"] {
font-family: var(--font-arab), var(--font-sans), ui-sans-serif, sans-serif;
--leading-body: 1.75;
--leading-prose: 1.85;
}
[lang="fa"] .typeset {
--typeset-leading: 1.75;
--typeset-flow: 1.45em;
--typeset-after-heading: 0.75em;
}Building a typeset
Long-form HTML uses the shipped .typeset class. It reads the rhythm variables, Cubix font tokens, and a 65ch measure:
.typeset {
--typeset-font-body: var(--font-sans);
--typeset-font-heading: var(--font-heading);
--typeset-font-mono: var(--font-mono);
--typeset-size: var(--text-body);
--typeset-leading: var(--leading-body);
--typeset-flow: 1.25em;
--typeset-after-heading: 0.5em;
--typeset-measure: var(--container-prose);
--typeset-tracking: var(--tracking-body);
max-width: var(--typeset-measure);
font-family: var(--typeset-font-body);
font-size: var(--typeset-size);
line-height: var(--typeset-leading);
letter-spacing: var(--typeset-tracking);
text-wrap: pretty;
}Keep tokens and utilities in the same CSS entry you already use for Cubix:
@import "tailwindcss";
/* Cubix tokens and utilities */
@import "./globals.css";This documentation shell already seeds rhythm on .docs-prose:
.docs-prose {
--typeset-size: var(--text-body);
--typeset-leading: var(--leading-prose);
--typeset-flow: 1.35em;
letter-spacing: var(--tracking-body);
}Presets
A typeset is a small preset class. Keep more than one in the same app - tighter for chat, roomier for docs:
.typeset-docs {
--typeset-size: var(--text-body);
--typeset-leading: var(--leading-prose);
--typeset-flow: 1.35em;
}
.typeset-chat {
--typeset-size: var(--text-description);
--typeset-leading: 1.6;
--typeset-flow: 1em;
--typeset-measure: none;
}
.typeset-large {
--typeset-size: var(--text-lg);
--typeset-leading: 1.75;
--typeset-flow: 1.5em;
}<h1 className="font-heading text-display">Page title</h1>
<p className="text-lead text-muted-foreground">Intro copy.</p>
<article className="typeset typeset-docs">{page}</article>
<div className="typeset typeset-chat">{message}</div>For a one-off tweak, set a variable on the container:
<article className="typeset [--typeset-flow:1.75em] [--typeset-measure:75ch]">
...
</article>Accessibility and dark mode
Offer a larger preset for readers who need more space. Dark mode already follows Theming tokens; loosen leading on dark surfaces if copy feels tight:
.typeset-large {
--typeset-size: var(--text-lg);
--typeset-leading: 1.75;
--typeset-flow: 1.5em;
}
.dark .typeset {
--typeset-leading: 1.7;
}
.dark .typeset-docs {
--typeset-leading: 1.8;
}
.dark .typeset-large {
--typeset-leading: 1.85;
}Overrides and opt-out
Prefer low-specificity selectors so Tailwind utilities win without !important:
<div className="typeset typeset-docs">
<p className="text-lead">Utility wins over typeset defaults.</p>
</div>Keep interactive Cubix components out of prose styling with not-typeset:
<div className="typeset typeset-docs">
<p>Styled prose.</p>
<Card className="not-typeset">Untouched component.</Card>
</div>In practice
Same roles in Persian - IRANSans XV, RTL, and the documented sizes.
طراحی سیستم تایپ کوبیکس
عنوان صفحه محصول
عنوان بخش
متن lead با سایز ۱۷ پیکسل و فاصله خطوط باز - برای پاراگراف اول صفحه.
متن بدنه روی ۱۵ پیکسل و ارتفاع خط ۱٫۶۵ است؛ عرض خواندن نزدیک ۶۵ نویسه. این همان ستون خواندنی برای مستندات و مقاله است.
پاراگراف دوم فاصلهاش را از ریتم Typeset میگیرد، نه از حاشیه جداگانه روی هر تگ.
متن کمکی رابط با text-description - ۱۴ پیکسل.
برچسب فیلد - ۱۳ پیکسل
راهنمای زیر ورودی با text-caption - ۱۲ پیکسل.