---
url: /reference/interface/ui-components/heading.md
---
# Heading

标题用于呈现页面或区块的层级标题，对应 HTML 的 `h1`–`h6`。

## 使用

::: code-group

```ts [Angular]
import { NxHeading } from "@pc-nexus/angular";
```

```ts [React]
import { NxHeading } from "@pc-nexus/react";
```

:::

## 属性

:::comp-props

| 名称 | 类型                                           | 必填 | 描述                          |
| ---- | ---------------------------------------------- | ---- | ----------------------------- |
| `as` | `'h1' \| 'h2' \| 'h3' \| 'h4' \| 'h5' \| 'h6'` |      | 渲染的标题标签，默认 `h1`     |
| `id` | `string`                                       |      | 元素 id，可用于锚点或关联标签 |

:::

## 示例

### Basic

通过 `as` 指定标题层级，取值可以为 `'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'`。

:::demo src=heading-basic
:::

### Color

Heading 放在带背景色的 `Box` 中时，可通过样式类设置对比色以保证可读性。

:::demo src=heading-color
:::
