Type scale and prose
Font sizes come from TEXT_SIZE, which picks the desktop or phone step; multi-line small text uses TEXT_SIZE.smallLoose. Markdown bodies and rich-text editors use the library’s prose recipes proseClasses / PROSE_EDITOR instead of hand-written text-[13px] or stacked leading-*.
Type scale
Section titled “Type scale”Write TEXT_SIZE.<step> in code; it picks the desktop or phone class (font size is not a theme token, so it can’t be swapped and is chosen at the class level). Size and line height come together in one class; don’t stack leading-* on it: a stacked value doesn’t change per platform and ends up tighter on phones.
TEXT_SIZE |
Desktop size / line height | Phone | Used for |
|---|---|---|---|
heading |
21 / 28 | 20 / 26 | Page titles, the page-header greeting |
title |
16 / 24 | 17 / 24 | Section and dialog titles, Markdown headings |
body |
13 / 20 | 16 / 24 | Body text, list rows, inputs |
small |
12 / 16 | 14 / 20 | Secondary notes, supporting table columns |
smallLoose |
12 / 18 | 14 / 22 | Small text over two lines or more: summaries, notes, descriptions, tooltips |
caption |
11 / 14 | 12 / 16 | Timestamps, counts, index dots |
Two steps appear on one platform only and have no TEXT_SIZE entry; write their classes directly: the dashboard metric text-metric (34 / 40) on desktop and the phone page title text-m-large (28 / 34).
The scale comes from fontSize in packages/ui/tailwind.json. The theme generator copies it into tailwind.fontSize in the workbench and gallery configurations. Don’t write raw sizes such as text-[15px]: between two steps, pick one and use weight and color for hierarchy. When a character is used as a graphic (★, ●), use an Icon sized as an icon instead of a font size.
Markdown bodies: proseClasses
Section titled “Markdown bodies: proseClasses”Pass proseClasses(kind, root?) to a TextView’s classes: body text is always text-body, headings text-title, links text-brand-text; only the line height has two steps.
'message'(default): line height 20. Chat bubbles, Copilot answers, translation blocks.'article': line height 24. Long-form text such as announcements.
The second argument adds classes to the root, text-foreground by default; inside a bubble pass the bubble’s own foreground.
import { TextView } from 'nsh/base'import { proseClasses } from 'nacre'
<TextView markdown={notice.content} links="open" classes={proseClasses('article')} /><TextView markdown={message.text} links="open" classes={proseClasses('message', 'text-bubble-self-foreground')} />Rich-text editors: PROSE_EDITOR
Section titled “Rich-text editors: PROSE_EDITOR”Use PROSE_EDITOR.paragraph / PROSE_EDITOR.marks for a RichEditor’s paragraphs and inline marks: the same size and line height as proseClasses('message'), so text looks the same while typing and after sending. Padding, caret, placeholder and images are passed per editor:
<RichEditor editor={editor} classes={{ content: 'px-2 py-1.5', placeholder: 'text-muted-foreground', nodes: { paragraph: PROSE_EDITOR.paragraph, image: 'max-h-[96px] rounded-md' }, marks: PROSE_EDITOR.marks, }}/>