# @csstools/postcss-text-decoration-shorthand 中文文档

规范地址：https://npmcn.com/package/%40csstools/postcss-text-decoration-shorthand/

版本：5\.0\.7
npm 元数据更新时间：2026-10-02T15:55:08.054Z
中文译文更新时间：2026-11-11T03:28:24.177Z
软件包许可：MIT-0

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

原始 npm 页面：https://www.npmjs.com/package/%40csstools/postcss-text-decoration-shorthand
原文对照：https://npmcn.com/package/%40csstools/postcss-text-decoration-shorthand/?lang=original
项目主页：https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-text-decoration-shorthand#readme
源码仓库：https://github.com/csstools/postcss-plugins

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

- 包体积（解压后）：8.8 kB，6 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=20\.19\.0
- 运行依赖：2 个
- peer 依赖：postcss ^8\.4
- 首次发布：2022-08-15T08:34:40.539Z
- 最新版本发布：2026-10-02T15:55:07.885Z
- 近 30 天下载量：25576424（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：29（近 12 个月 8 个）

## 中文简介

使用 CSS 中的简写格式

## 安装

```sh
npm install @csstools/postcss-text-decoration-shorthand
```

也可以使用：`pnpm add @csstools/postcss-text-decoration-shorthand`、`yarn add @csstools/postcss-text-decoration-shorthand`、`bun add @csstools/postcss-text-decoration-shorthand`

## README

# PostCSS 文本装饰简写 [![PostCSS Logo](https://postcss.github.io/postcss/logo.svg)](https://github.com/postcss/postcss)

`npm install @csstools/postcss-text-decoration-shorthand --save-dev`

[PostCSS 文本装饰简写](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-text-decoration-shorthand) 让您使用 `text-decoration` 作为紧随 [文字装饰规格](https://drafts.csswg.org/css-text-decor-4/#text-decoration-property)。 。 。 .

```css
.example {
    text-decoration: wavy underline purple 25%;
}

/* becomes */

.example {
    text-decoration: underline;
    text-decoration: underline wavy purple;
    text-decoration-thickness: calc(0.01em * 25);
    text-decoration: wavy underline purple 25%;
}
```

## 使用量

添加 [PostCSS 文本装饰简写](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-text-decoration-shorthand) 对您的项目:

```bash
npm install postcss @csstools/postcss-text-decoration-shorthand --save-dev
```

当作一个 [邮政](https://github.com/postcss/postcss) 插件 :

```js
const postcss = require('postcss');
const postcssTextDecorationShorthand = require('@csstools/postcss-text-decoration-shorthand');

postcss([
    postcssTextDecorationShorthand(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
```

## 选项

### 保护

这个 `preserve` 选项决定原始标记是否 被保存下来。 默认保存.

```js
postcssTextDecorationShorthand({ preserve: false })
```

```css
.example {
    text-decoration: wavy underline purple 25%;
}

/* becomes */

.example {
    text-decoration: underline;
    text-decoration: underline wavy purple;
    text-decoration-thickness: calc(0.01em * 25);
}
```

## 常见问题

### @csstools/postcss-text-decoration-shorthand 是什么？

使用 CSS 中的简写格式

### 如何安装 @csstools/postcss-text-decoration-shorthand？

在项目目录运行 npm install @csstools/postcss-text-decoration-shorthand，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：postcss（^8\.4）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @csstools/postcss-text-decoration-shorthand 支持 TypeScript 吗？

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

### @csstools/postcss-text-decoration-shorthand 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @csstools/postcss-text-decoration-shorthand 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=20\.19\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @csstools/postcss-text-decoration-shorthand 可以商用吗？

@csstools/postcss-text-decoration-shorthand 使用 MIT-0 许可。声明的许可为 MIT-0，请阅读许可原文确认使用条件。以上为概括，不构成法律意见，请以许可原文为准。

### @csstools/postcss-text-decoration-shorthand 的下载量有多少？

根据 npm 官方下载统计，@csstools/postcss-text-decoration-shorthand 在 2026/10/11 – 2026/11/09 这 30 天内被下载 25,576,424 次，日均约 852,547 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @csstools/postcss-text-decoration-shorthand 还在维护吗？

最新版本 5\.0\.7 发布于 2026/10/02（1 个月前）；至今共发布 29 个版本，其中过去 12 个月发布了 8 个；首次发布于 2022/08/15。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

