---
title: "TextStyle 扩展"
description: "在 Tiptap 中使用文本样式扩展添加具有自定义样式的 标签。更多信息请查看我们的文档！"
canonical_url: "https://tiptap.zhcndoc.com/editor/extensions/marks/text-style"
---

# TextStyle 扩展

在 Tiptap 中使用文本样式扩展添加具有自定义样式的 标签。更多信息请查看我们的文档！

该标记呈现一个 `<span>` HTML 标签，并允许您添加一系列与样式相关的属性，例如字体系列、字体大小或颜色。该扩展默认不添加任何样式属性，但其他扩展将其作为基础，例如 [`FontFamily`](https://tiptap.zhcndoc.com/editor/extensions/functionality/fontfamily.md) 或 [`Color`](https://tiptap.zhcndoc.com/editor/extensions/functionality/color.md)。

> **Interactive demo:** [Textstyle](https://embed.tiptap.dev/preview/Marks/Textstyle)

## 安装

```bash
npm install @tiptap/extension-text-style
```

## 命令

### removeEmptyTextStyle()

移除没有内联样式的 `<span>` 标签。

```js
editor.command.removeEmptyTextStyle()
```

## 源代码

[packages/extension-text-style/](https://github.com/ueberdosis/tiptap/blob/main/packages/extension-text-style/)
