字阶与正文排版
字号经 TEXT_SIZE 取字阶(按端给桌面或手机的值),多行小字用 TEXT_SIZE.smallLoose;Markdown 正文与富文本编辑器用库里的排版配方 proseClasses / PROSE_EDITOR,不手写 text-[13px]、不叠 leading-*。
字阶
定位到「字阶」代码里写 TEXT_SIZE.<档>,它按端取桌面或手机的字阶类(字号不是主题 token,换不了,只能在类名层分端)。字号与行高打包在一个类里,不再叠 leading-*:叠的值不随端变,手机上反而更紧。
TEXT_SIZE |
桌面 字号 / 行高 | 手机 | 用在 |
|---|---|---|---|
heading |
21 / 28 | 20 / 26 | 页面标题、页头问候 |
title |
16 / 24 | 17 / 24 | 区块、弹窗标题,Markdown 小标题 |
body |
13 / 20 | 16 / 24 | 正文、列表行、输入框 |
small |
12 / 16 | 14 / 20 | 次要说明、表格辅助列 |
smallLoose |
12 / 18 | 14 / 22 | 两行以上的小号正文:摘要、小记、说明、提示气泡 |
caption |
11 / 14 | 12 / 16 | 时间戳、计数、序号圆点 |
没有 TEXT_SIZE 档的两个只在一端出现,直接写类名:桌面看板指标 text-metric(34 / 40)、手机页面大标题 text-m-large(28 / 34)。
字号来自 packages/ui/tailwind.json 的 fontSize。主题生成器将它同步到工作台和画廊配置的 tailwind.fontSize。不写 text-[15px] 这类裸字号:介于两档之间时选一档,层级靠字重和颜色补。字符当图形用(★、●)时换成 Icon,尺寸按图标给,不靠字号。
Markdown 正文:proseClasses
定位到「Markdown 正文:proseClasses」TextView 的 classes 用 proseClasses(kind, root?):正文一律 text-body,小标题 text-title,链接 text-brand-text;只有行距分两档。
'message'(默认):行高 20。聊天气泡、Copilot 回答、翻译块。'article':行高 24。通知公告这类成篇长文。
第二个参数是根节点的附加类,默认 text-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')} />富文本编辑器:PROSE_EDITOR
定位到「富文本编辑器:PROSE_EDITOR」RichEditor 的段落与行内标记用 PROSE_EDITOR.paragraph / PROSE_EDITOR.marks,和 proseClasses('message') 同字号同行距,输入时与发出去后看起来一样。内边距、光标、占位、图片按编辑器自己的位置另传:
<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, }}/>