---
title: Heading 标题
description: 带锚点与悬停复制链接按钮的标题。
---

`heading()` 渲染带锚点的标题：点击文本跳转到锚点，悬停/聚焦时出现 ghost
复制按钮，复制 `#<id>` 链接。

## 层级

```ts
heading(2, '安装', { id: 'installation' });
heading(3, '从源码安装', { id: 'from-source' });
heading(3, '从仓库安装', { id: 'from-registry' });
```

## 步骤标题

```ts
heading(2, '创建账号', { id: 'create-account', step: true });
```

## 参数

<PropsTable
  labels={{ prop: '参数', type: '类型' }}
  type={{
    level: { type: '1–6', description: '标题层级（第一个参数）。' },
    text: { type: 'string', description: '标题文本（第二个参数）。' },
    id: { type: 'string', description: '锚点 id——复制链接按钮也使用它。' },
    step: { type: 'boolean', description: '标记为 Plumest TOC 阶数项（<code>data-cpd-step</code>）。' },
  }}
/>

## 注意

- 锚点链接为 `href="#<id>"`；复制按钮复制 `location.origin + pathname + #<id>`
  绝对地址。
- `step` 标题在文章内渲染阶数徽标，并在 Plumest TOC 中显示编号徽章。
