跳至主要内容

Typography

在 ChatGPT 中打开

排版令牌用于在您的应用程序中保持一致的字体样式集。

字体家族

字体家族属性用于指定优先字体家族名称的列表。

系统字体堆栈默认使用 system-ui,它会自动解析为平台的本地字体:

  • 在 macOS 和 iOS 上为 San Francisco
  • 在 Windows 上为 Segoe UI
  • 在 Android 和 Chrome OS 上为 Roboto

您可以使用 --dwc-font-family 自定义属性来应用或更改字体家族。

示例

:root {
--dwc-font-family: "Roboto", sans-serif;
}

变量

变量默认值
--dwc-font-family-sanssystem-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'
--dwc-font-family-monoui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace
--dwc-font-familyvar(--dwc-font-family-sans)

字体大小

字体大小属性定义了一组可供选择的字体大小。m 是标准大小,默认由大多数组件使用。所有字体大小以 rem 为单位定义。

REM 单位

rem 是相对长度单位。它相对于根元素 (<html>) 的字体大小,在大多数浏览器中默认是 16px。

示例

.title {
font-size: var(--dwc-font-size-3xl);
}

变量

变量默认值计算(在 16px 根元素下)
--dwc-font-size-3xs0.625rem10px
--dwc-font-size-2xs0.6875rem11px
--dwc-font-size-xs0.75rem12px
--dwc-font-size-s0.8125rem13px
--dwc-font-size-m0.875rem14px
--dwc-font-size-l1rem16px
--dwc-font-size-xl1.25rem20px
--dwc-font-size-2xl1.625rem26px
--dwc-font-size-3xl2.125rem34px
--dwc-font-sizevar(--dwc-font-size-m)14px

字体粗细

font-weight CSS 属性设置字体的粗细(或加粗程度)。

示例

p {
font-weight: var(--dwc-font-weight-semibold);
}
变量默认值
--dwc-font-weight-thin100
--dwc-font-weight-lighter200
--dwc-font-weight-light300
--dwc-font-weight-normal400
--dwc-font-weight-medium500
--dwc-font-weight-semibold600
--dwc-font-weight-bold700
--dwc-font-weight-bolder800
--dwc-font-weight-black900
--dwc-font-weightvar(--dwc-font-weight-normal)

行高

line-height CSS 属性设置行框的高度。它通常用于设置文本行之间的距离。

示例

p {
line-height: var(--dwc-font-line-height-m);
}

变量

变量默认值
--dwc-font-line-height-3xs1
--dwc-font-line-height-2xs1.1
--dwc-font-line-height-xs1.25
--dwc-font-line-height-s1.375
--dwc-font-line-height-m1.5
--dwc-font-line-height-l1.625
--dwc-font-line-height-xl1.75
--dwc-font-line-height-2xl1.875
--dwc-font-line-height-3xl2
--dwc-font-line-heightvar(--dwc-font-line-height-xs)