2020-08-19 03:39:41 +08:00
# Heading
2021-01-25 17:35:52 +08:00
[![Version ](https://img.shields.io/npm/v/@tiptap/extension-heading.svg?label=version )](https://www.npmjs.com/package/@tiptap/extension-heading)
[![Downloads ](https://img.shields.io/npm/dm/@tiptap/extension-heading.svg )](https://npmcharts.com/compare/@tiptap/extension-heading?minimal=true)
2020-09-27 16:40:08 +08:00
The Heading extension adds support for headings of different levels. Headings are rendered with `<h1>` , `<h2>` , `<h3>` , `<h4>` , `<h5>` or `<h6>` HTML tags. By default all six heading levels (or styles) are enabled, but you can pass an array to only allow a few levels. Check the usage example to see how this is done.
2020-09-11 03:13:18 +08:00
2020-09-27 16:40:08 +08:00
Type < code > # < / code > at the beginning of a new line and it will magically transform to a heading, same for < code > ## < / code > , < code > ### < / code > , < code > #### < / code > , < code > ##### < / code > and < code > ###### < / code > .
2020-08-19 03:39:41 +08:00
2020-09-23 15:52:04 +08:00
## Installation
```bash
2020-10-30 21:24:16 +08:00
# with npm
2020-09-23 15:52:04 +08:00
npm install @tiptap/extension -heading
2020-10-30 21:24:16 +08:00
# with Yarn
2020-09-23 15:52:04 +08:00
yarn add @tiptap/extension -heading
```
2020-09-23 18:03:03 +08:00
## Settings
2020-11-18 19:12:34 +08:00
| Option | Type | Default | Description |
| -------------- | -------- | -------------------- | --------------------------------------------------------------------- |
| HTMLAttributes | `Object` | `{}` | Custom HTML attributes that should be added to the rendered HTML tag. |
| levels | `Array` | `[1, 2, 3, 4, 5, 6]` | Specifies which heading levels are supported. |
2020-08-19 03:39:41 +08:00
2020-08-20 21:33:16 +08:00
## Commands
2020-11-03 23:43:35 +08:00
| Command | Parameters | Description |
| ------- | ---------- | ------------------------------------------------ |
| heading | level | Creates a heading node with the specified level. |
2020-08-19 03:39:41 +08:00
2020-09-10 17:24:33 +08:00
## Keyboard shortcuts
2020-09-27 17:01:25 +08:00
* Windows/Linux: `Control` `Alt` `1-6`
* macOS: `Cmd` `Alt` `1-6`
2020-08-19 03:39:41 +08:00
2020-09-21 22:59:28 +08:00
## Source code
2021-04-21 21:31:11 +08:00
[packages/extension-heading/ ](https://github.com/ueberdosis/tiptap/blob/main/packages/extension-heading/ )
2020-08-19 03:39:41 +08:00
2020-09-10 23:10:20 +08:00
## Usage
2021-08-26 05:10:20 +08:00
< tiptap-demo name = "Nodes/Heading" > < / tiptap-demo >