# @entur/typography 中文文档

规范地址：https://npmcn.com/package/%40entur/typography/

版本：3\.2\.0
npm 元数据更新时间：2026-11-02T14:45:46.257Z
中文译文更新时间：2026-11-13T18:40:24.115Z
软件包许可：SEE LICENSE IN README\.md

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40entur/typography
原文对照：https://npmcn.com/package/%40entur/typography/?lang=original
项目主页：https://github.com/entur/design-system#readme
源码仓库：https://github.com/entur/design-system

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：4 MB，139 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：5 个
- peer 依赖：react \>=18\.0\.0，react-dom \>=18\.0\.0
- 首次发布：2019-09-25T12:27:58.201Z
- 最新版本发布：2026-11-02T14:45:46.024Z
- 近 30 天下载量：36280（2026-10-14 至 2026-11-12，npm 官方下载统计）
- 已发布版本数：223（近 12 个月 33 个）

## 中文简介

Entur的官方字体为Nationale,由位于哥本哈根的Playtype Foundry所创建. 该字体受许可证保护,只能用于官方Entur产品. 通过下载此字体, 您确认您受雇于 Entur and Th

## 安装

```sh
npm install @entur/typography
```

也可以使用：`pnpm add @entur/typography`、`yarn add @entur/typography`、`bun add @entur/typography`

## README

# 类型

## 使用前读取

Entur的官方字体为Nationale,由位于哥本哈根的Playtype Foundry所创建. 该字体受许可证保护,只能用于官方Entur产品. 通过下载此字体, 您确认您为 Entur 所使用, 而该字体将只用于开发 Entur 的官方产品 . **所有其他用途都将被视为违反许可协议和Entur品牌,并可提起法律诉讼.**

这个软件包包含样式和回放组件,用于我们所有的打字.

> 寻找 [文档](https://linje.entur.no/komponenter/ressurser/typography)? 吗? 寻找β [文档](https://linje.entur.no/komponenter/ressurser/typography-beta)? 吗?

## 安装

```bash
npm install @entur/typography
# or
yarn add @entur/typography
```

## QQ 快速启动

### 使用稳定打字法(建议生产)

```typescript
import { Heading1, Paragraph, Link } from '@entur/typography';
import '@entur/typography/styles';

function MyComponent() {
  return (
    <div>
      <Heading1>My Title</Heading1>
      <Paragraph>My content</Paragraph>
      <Link href="/more">Learn more</Link>
    </div>
  );
}
```

### 使用 Beta 图案( 实验特性)

```typescript
import { Heading, Text, Link } from '@entur/typography/beta';
import '@entur/typography/styles';
import '@entur/typography/beta/styles';

function MyComponent() {
  return (
    <div>
      <Heading as="h1" variant="title-1">
        My Title
      </Heading>
      <Text variant="paragraph">My content</Text>
      <Link href="/more">Learn more</Link>
    </div>
  );
}
```

## \* 移徙

**有好消息吗!** 这个软件包保持了完全后向相容性. 所有现有的进口模式仍然与以前一样有效.

### 后向兼容性

```typescript
// ✅ All these still work exactly as before
import { Heading1 } from '@entur/typography/dist/Heading1';
import { Paragraph } from '@entur/typography/dist/Paragraph';
import '@entur/typography/dist/styles.css';
```

### 现代进口(建议)

```typescript
// 🚀 But these are now preferred
import { Heading1, Paragraph } from '@entur/typography';
import '@entur/typography/styles';
```

### 移动到新打字机

使用 [`migrate-typography`](https://github.com/entur/design-system/tree/main/skills/migrate-typography) 与您的 AI 编码代理。 它涵盖旧的部件(`Heading1`– 说吧 –`6`, (中文(简体) ), `Paragraph` ...),β变化和布局β间距尺度.

### 更新样式

```scss
// Replace this
@import '@entur/typography/dist/styles.css';

// With this
@import '@entur/typography/styles';
```

## \* 特性

### Β 类型

-   **语义变体** - 标题、字幕、段落等.
-   **大小变体** - 特别大、大、中、小、多
-   **重量变量** - 中和大胆
-   **默认无边距** - 无论你放在哪里,文本都会被冲走
-   **间距** - 说吧 `spacing="m"` 或者说 `spacing={{ top: 's', bottom: 'xl' }}`,与 `gap` 内 `@entur/layout/beta`
-   **文本连接器** - 环绕正在运行的文本,以获得标题、段落和列表之间的节奏
-   **无障碍** - 内建的ARIA支持和语义HTML

### 传统类型

-   **单个构成部分** - 标题1-6、段落、链接等.
-   **简单 API** - 易于使用,配置最小
-   **后向兼容性** - 现行守则继续有效

## 许可证

-   源代码根据欧洲联盟公共许可证第1.2版(欧盟PL-1.2)获得许可
-   字体单独许可使用,所有使用均应遵循其许可使用.

## 常见问题

### @entur/typography 是什么？

Entur的官方字体为Nationale,由位于哥本哈根的Playtype Foundry所创建\. 该字体受许可证保护,只能用于官方Entur产品\. 通过下载此字体, 您确认您受雇于 Entur and Th

### 如何安装 @entur/typography？

在项目目录运行 npm install @entur/typography，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（\>=18\.0\.0）、react-dom（\>=18\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @entur/typography 支持 TypeScript 吗？

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

### @entur/typography 支持 ESM 还是 CommonJS？

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

### @entur/typography 可以商用吗？

@entur/typography 使用 SEE LICENSE IN README\.md 许可。许可条款写在包内的独立文件中，请阅读该文件确认可否商用。以上为概括，不构成法律意见，请以许可原文为准。

### @entur/typography 的下载量有多少？

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

### @entur/typography 还在维护吗？

最新版本 3\.2\.0 发布于 2026/11/02（11 天前）；至今共发布 223 个版本，其中过去 12 个月发布了 33 个；首次发布于 2019/09/25。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

