简体中文
字体
组件不指定正文字族:皮肤里写的是 font-family: inherit,控件与面板跟着宿主页面的字走,库只定等宽字族、字号阶梯、字重、行高与排版角色。层级由字号、字重、行高和间距共同表达,不能只调颜色。
字族
| 令牌 | 取值 | 说明 |
|---|---|---|
--xh-font-family-mono | ui-monospace, SFMono-Regular, Menlo, Consolas, monospace | 代码、密钥、哈希、快捷键:Kbd、Clipboard、CodeView、JsonViewer、Typography 的 code |
正文字族由宿主决定。文档站用的是 Inter 与系统无衬线字,那是文档站的选择,不是库的默认。中后台产品建议用系统字栈(-apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif 一类),数字密集的表格与统计面板打开 font-variant-numeric: tabular-nums——NumberField、Statistic、Timer、Timestamp、Clipboard、分段日期与时间框已自带。
字号阶梯
九档,以 rem 记,随宿主根字号缩放:
| 令牌 | 取值 | 预览 | 说明 |
|---|---|---|---|
--xh-font-size-xs | 0.75rem | 12px · 次级标注:计数、快捷键、时间戳、序号 | |
--xh-font-size-sm | 0.8125rem | 13px · 说明、sm 档控件 | |
--xh-font-size-md | 0.875rem | 14px · 正文、标签、浮层内与小面标题、md 档控件 | |
--xh-font-size-lg | 1rem | 16px · heading-3:区块与面板标题;lg 档控件 | |
--xh-font-size-xl | 1.25rem | 20px · heading-2:页面标题 | |
--xh-font-size-2xl | 1.5rem | 24px · heading-1 | |
--xh-font-size-3xl | 1.75rem | 28px · display:大号数值的 lg 档 | |
--xh-font-size-4xl | 2rem | 32px · 原语储备,暂无语义角色取用 | |
--xh-font-size-5xl | 2.25rem | 36px · 原语储备,暂无语义角色取用 |
控件字号随尺寸档:--xh-control-font-sm / md / lg = 13 / 14 / 16px;控件里的次级文字(提示、计数、快捷键、清空钮、标签项)取 --xh-control-caption-*,比同档主文字低一级。密度不改字号。
字重与行高
| 令牌 | 取值 | 说明 |
|---|---|---|
--xh-font-weight-regular | 400 | 正文、字段标签、集合标题、按钮字 |
--xh-font-weight-medium | 500 | 各级标题(heading-1 / 2 / 3)、浮层内与小面标题、选中的候选项、导航当前项、表格列头、当前页的面包屑 |
--xh-font-weight-semibold | 600 | SideNav 当前项;标题统一取 medium,不用它 |
--xh-font-weight-bold | 700 | 只给 Typography 的加粗与个别强调(打印时的 Alert 标题、日历的今天) |
--xh-leading-none | 1 | 单行标签、控件内文字 |
--xh-leading-tight | 1.25 | 标题、色板标注 |
--xh-leading-normal | 1.5 | 正文、说明 |
--xh-leading-relaxed | 1.625 | 长文(Typography 的段落) |
排版角色
皮肤按角色取值,不直接取字号原语;门禁 check-text-role 逐条核。
| 角色 | 字号 / 字重 / 颜色 | 与相邻元素的间距 |
|---|---|---|
| 字段标签(单字段与 Slider、Rating、Signature、Color* 等复合单字段) | --xh-text-label-size 14 / --xh-text-label-weight 400 / --xh-fg-muted | 竖排与控件 --xh-space-2;Form 横排时标签列占一行的 5 / 24、与控件 --xh-space-4 |
| 集合标题(RadioGroup、CheckboxGroup、Listbox、Tree、TagGroup、Descriptions) | 14 / --xh-text-label-weight 400 / --xh-fg-muted | 与集合 --xh-space-2 |
| 整行控件的标签(Checkbox、Switch) | 随档 --xh-control-font-sm / md / lg / regular / --xh-fg-default,禁用 --xh-fg-subtle | 与方框 --xh-space-2 |
| 字段说明 / helper(Field、Fieldset) | --xh-text-caption-size 12 / --xh-fg-subtle / --xh-leading-normal;禁用不另变色 | 紧贴控件,辅助行最小高 --xh-space-5 |
| 其余说明(Card、Alert、Dialog 等面内的 description) | --xh-text-secondary-size 13 / --xh-fg-muted / --xh-leading-normal;Steps 的步骤说明取次级标注 12 / --xh-fg-subtle | — |
| 错误文案 | 12 / --xh-fg-danger | 与说明共用控件下方那一行辅助行 |
| 浮层内与小面标题(Popover、HoverCard、Popconfirm、FloatingPanel、Approval、EmptyState、Citation) | 14 / --xh-font-weight-medium | — |
| 区块与面板标题(Card、Descriptions、Alert、Notification、Steps;Dialog、Drawer、Tour) | heading-3(--xh-text-heading-3-*):16 / 500 | — |
| 页面标题(PageHeader) | heading-2(--xh-text-heading-2-*):20 / 500 | — |
| 大号数值(Statistic、Timer、NumberAnimation) | sm / md / lg 依次取 heading-2 / heading-1 / display(--xh-text-display-size):20 / 24 / 28 | — |
| 次级标注(计数、快捷键、时间戳、序号) | --xh-text-caption-size 12 | — |
| 代码 | --xh-font-family-mono / --xh-text-code-leading 1.5rem | — |
必填星号与错误文案是公共层规则:星号 --xh-glyph-mark-required 排在标签文字之前,取 --xh-text-caption-size + --xh-fg-danger、与文字隔 --xh-space-1,自带标签的字段不各画一套;字段标签与字段说明禁用不另变色,其余标签禁用取 --xh-fg-subtle;单行标签 --xh-leading-none。
文案
- 标签是名词或名词短语,不带冒号;说明是一句完整的话,句末不加句号;错误文案说清楚"怎么改",不只说"格式不对"。
- 按钮是动词或动宾短语("保存"、"删除标签"),主要动作只有一个;破坏性动作用 danger 语气并在 Popconfirm 里二次确认。
- 空状态说清楚"为什么空"与"下一步做什么",EmptyState 自带动作位。
- 数字用
tabular-nums对齐,时间用 Timestamp 按本地化格式化,不手拼。
相关
- 布局 · 图标
- 指南:设计令牌与主题 · 排版角色 · 国际化
