¥Typography
字体使用和调整指南。
¥Base components
使用 文本 和 标题 组件渲染标题和正文。这些组件共享 size
和 weight
props,并映射到底层类型系统,以确保整个应用的排版一致。
¥Use Text and Heading components to render titles and body copy. These components share size
and weight
props and map to the underlying type system to ensure consistent typography throughout your app.
¥Formatting components
组合格式化组件以添加 emphasis、信号重要性、呈现 code 等。
¥Compose formatting components to add emphasis, signal importance, present code and more.
¥Type scale
排版系统基于 9 级 size
比例。每个步骤都有相应的字体大小、行高和字母间距值,这些值均设计为可组合使用。
¥The typographic system is based on a 9-step size
scale. Every step has a corresponding font size, line height and letter spacing value which are all designed to be used in combination.
¥Font weight
支持以下粗细。可以将字重设置为 customized,以映射到你自己的字体。
¥The following weights are supported. Weights can be customized to map to your own typeface.
¥Font family
默认情况下,Radix Themes 使用系统字体堆栈来实现可移植性和易读性。继续阅读下一部分,了解如何使用自定义字体自定义主题。
¥By default, Radix Themes uses a system font stack for portability and legibility. Continue to the next section to learn about customizing your theme with a custom font.
¥Customization
Radix Themes 的字体可以通过覆盖 token 系统相应的 CSS 变量进行自定义。有关排版标记的完整列表,请参阅 源代码。
¥Radix Themes typography can be customized by overriding the corresponding CSS variables of the token system. Refer to the source code for the full list of the typographic tokens.
确保你的 CSS 在 Radix Themes 样式之后应用,以便其优先。
¥Make sure that your CSS is applied after the Radix Themes styles so that it takes precedence.
¥Custom fonts
你可以提供自己的字体,但是,如何导入和使用它们取决于你。你只需使用正确的语法指定命名字体即可。
¥You can provide your own fonts, however, how you choose to import and serve them is up to you. It is only required that you specify your named fonts using the correct syntax.
要自定义主题中使用的字体系列,请重新映射相应的 font-family
标记:
¥To customize the font family used in your theme, remap the corresponding font-family
tokens:
¥With next/font
要通过 next/font 加载自定义字体,请使用 variable
选项定义 CSS 变量名。然后,将该 CSS 变量类添加到你的 HTML 文档中。
¥To load custom fonts via next/font, use the variable
option to define a CSS variable name. Then, add that CSS variable class to your HTML document.
最后,在你的自定义 CSS 中分配 CSS 变量:
¥Finally, assign the CSS variable in your custom CSS:
请注意,如果你正在运行应用路由,可能会遇到 CSS 导入顺序问题。有关更多信息,请参阅 常见样式问题。
¥Be aware that you may encounter css import order issues if you are running the app router. See common styling issues for more information.
¥Custom font weights
要自定义主题中使用的确切字体粗细,请将相应的 font-weight
标记重新映射到你自己的值:
¥To customize the exact font weights used in your theme, remap the corresponding font-weight
tokens to your own values:
¥Advanced settings
有许多可自定义的高级排版功能。这些功能包括某些组件的字体大小乘数、字体样式、字母间距和行距修剪。例如,你可以自定义标题,使其使用比默认字体更大的字体大小、不同的行距修剪值和更紧密的字母间距进行渲染:
¥There’s a number of advanced typographic features that can be customized. These include a font size multiplier for certain components, font style, letter spacing, and leading trim. For example, you can customize the headings to render with a relatively larger font size than your default font, different leading trim values, and tighter letter spacing: