@asphalt-react/typography

中文文档
2.19.0发布于 2026/10/29UNLICENSEDTypeScriptESM + CJS近 30 天下载 1956

Typography

原始使用文档
文档目录47 节
  1. Usage
  2. Intents
  3. Figma Token Mapping
  4. Props
  5. children
  6. h1
  7. h2
  8. h3
  9. h4
  10. h5
  11. h6
  12. primary
  13. secondary
  14. brand
  15. onBrand
  16. muted
  17. Props
  18. children
  19. size
  20. p
  21. span
  22. div
  23. primary
  24. secondary
  25. brand
  26. onBrand
  27. muted
  28. Props
  29. children
  30. size
  31. Props
  32. children
  33. size
  34. bold
  35. p
  36. span
  37. div
  38. primary
  39. secondary
  40. brand
  41. onBrand
  42. danger
  43. warning
  44. info
  45. success
  46. muted
  47. ellipsis

Typography

npm npm version

Typography helps establish hierarchy and communicate text content clearly. Typography components abstracts over semantic and visuals. Some Typography components can have semantics meaning attached to it.

Typography components control the font property, other applicable styles are inherited by the global or user agent styles. In order to have more control apply the styles in parent container. The purpose of the typography components is to enable adding text content that is themeable.

You can use HTML Text content elements and Content sectioning elements to organize blocks or sections of content.

Use HTML Inline text semantics define the meaning, structure, or style of a word, line, or any arbitrary piece of text.

Usage

import {Heading, Display, Code, Text} from '@asphalt-react/typography'

<Heading>The quick brown fox jumps</Heading>

<Display>The quick brown fox jumps</Display>

<Code>npm install @asphalt-react/typography</Code>

<Text>The quick brown fox jumps</Text>

<Text bold>I have a higher font weight than Text</Text>

Intents

The Heading, Display & Text components have 5 intents to represent different content hierarchy and usages:

  • primary: This is the default intent and has the highest hierarchy.
  • secondary: This intent signifies copy with a lesser hierarchy than "primary".
  • muted: This intent has the lowest hierarchy and is usefult to show copy that should catch least user attention.
  • brand: This intent highlights the copy that closely represents the brand.
  • onBrand: This intent is useful to render a copy on brand colored surfaces. This intent ensures appropriate contrast ratio with the brand color.

Text additionally supports 4 semantic intents for status and feedback messaging:

  • info: a generic informational message.
  • success: information with a successful intent.
  • warning: information with a warning intent; demands more attention than info.
  • danger: critical information that demands the most attention. Used for information leading to destructive actions like removing a user.

Heading

Use Heading to represent the section heading contents, it supports all six levels of section headings from h1 till h6.

Figma Token Mapping

Each heading level maps to a Figma token and its corresponding CSS custom property:

PropHTML TagFigma Token
h1<h1>heading/2XL
h2<h2>heading/XL
h3<h3>heading/L
h4<h4>heading/M
h5<h5>heading/S
h6<h6>heading/XS

Props

children

React node for heading content.

typerequireddefault
nodetrueN/A

h1

Render the content as h1 section heading.

typerequireddefault
boolfalsefalse

h2

Render the content as h2 section heading.

typerequireddefault
boolfalsefalse

h3

Render the content as h3 section heading.

typerequireddefault
boolfalsefalse

h4

Render the content as h4 section heading.

typerequireddefault
boolfalsefalse

h5

Render the content as h5 section heading.

typerequireddefault
boolfalsefalse

h6

Render the content as h6 section heading.

typerequireddefault
boolfalsefalse

primary

Renders the text with primary intent. This is the default intent.

typerequireddefault
boolfalsefalse

secondary

Renders the text with secondary intent.

typerequireddefault
boolfalsefalse

brand

Renders the text with brand intent.

typerequireddefault
boolfalsefalse

onBrand

Renders the text with appropriate contrast ration to backgrounds with brand color.

typerequireddefault
boolfalsefalse

muted

Renders the text with muted intent.

typerequireddefault
boolfalsefalse

Display

Use Display to put more emphasis on a text. Use it to display a hero or marketing text.

Display by default renders the content in p tag, you can also choose to render in a div or span instead.

Props

children

React node for display content.

typerequireddefault
nodetrueN/A

size

Controls the size of display.

typerequireddefault
enumfalse"m"

p

render the display content in a p tag.

typerequireddefault
boolfalsefalse

span

render the display content in a span tag.

typerequireddefault
boolfalsefalse

div

render the display content in a div tag.

typerequireddefault
boolfalsefalse

primary

Renders the text with primary intent. This is the default intent.

typerequireddefault
boolfalsefalse

secondary

Renders the text with secondary intent.

typerequireddefault
boolfalsefalse

brand

Renders the text with brand intent.

typerequireddefault
boolfalsefalse

onBrand

Renders the text with appropriate contrast ratio to backgrounds with brand color.

typerequireddefault
boolfalsefalse

muted

Renders the text with muted intent.

typerequireddefault
boolfalsefalse

Code

Code styles text content in a fashion intended to indicate that the text is a short fragment or snippet of computer code.

Props

children

React node for code content.

typerequireddefault
nodetrueN/A

size

Controls the size of code content.

typerequireddefault
enumfalse"m"

Text

Use Text to render generic text contents. Text by default renders the text in p tag, you can also choose to render in a div or span instead.

Props

children

React node for text content.

typerequireddefault
nodetrueN/A

size

Controls the size of text.

typerequireddefault
enumfalse"m"

bold

Render the bold variant.

Bold variant is only supported for "xs", "s", "m" & "l" sizes.

typerequireddefault
boolfalseN/A

p

render the content in a p tag.

typerequireddefault
boolfalsefalse

span

render the content in a span tag.

typerequireddefault
boolfalsefalse

div

render the content in a div tag.

typerequireddefault
boolfalsefalse

primary

Renders the text with primary intent. This is the default intent.

typerequireddefault
boolfalsefalse

secondary

Renders the text with secondary intent.

typerequireddefault
boolfalsefalse

brand

Renders the text with brand intent.

typerequireddefault
boolfalsefalse

onBrand

Renders the text with appropriate contrast ratio to backgrounds with brand color.

typerequireddefault
boolfalsefalse

danger

Renders the text with danger intent.

typerequireddefault
boolfalsefalse

warning

Renders the text with warning intent.

typerequireddefault
boolfalsefalse

info

Renders the text with info intent.

typerequireddefault
boolfalsefalse

success

Renders the text with success intent.

typerequireddefault
boolfalsefalse

muted

Renders the text with muted intent.

typerequireddefault
boolfalsefalse

ellipsis

Truncates text with an ellipsis when it overflows its container.

typerequireddefault
boolfalsefalse

版本与发布记录

@asphalt-react/typography 共发布 30 个版本,首次发布于 2023/04/13;过去 12 个月发布了 12 个版本。

版本发布日期距今
2.19.0latest2026/10/2910 天前
2.18.02026/10/071 个月前
2.16.02026/07/283 个月前
2.15.32026/07/074 个月前
2.15.12026/04/286 个月前
2.15.02026/04/136 个月前

其他发布通道:next → 2.0.0-alpha.28。

关于 @asphalt-react/typography 的常见问题

@asphalt-react/typography 是什么?

Typography

如何安装 @asphalt-react/typography?

在项目目录运行 npm install @asphalt-react/typography,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>= 16.8.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@asphalt-react/typography 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@asphalt-react/typography 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@asphalt-react/typography 可以商用吗?

@asphalt-react/typography 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@asphalt-react/typography 的下载量有多少?

根据 npm 官方下载统计,@asphalt-react/typography 在 2026/10/07 – 2026/11/05 这 30 天内被下载 1,956 次,日均约 65 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@asphalt-react/typography 还在维护吗?

最新版本 2.19.0 发布于 2026/10/29(10 天前);至今共发布 30 个版本,其中过去 12 个月发布了 12 个;首次发布于 2023/04/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。