> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superdoc.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Heading extension

Create document structure with six heading levels.

Use headings to organize content hierarchically. Press <kbd>Cmd+Option+1-6</kbd> for quick heading shortcuts.

## OOXML Structure

```xml theme={null}
<w:p>
  <w:pPr>
    <w:pStyle w:val="Heading1"/>
  </w:pPr>
  <w:r>
    <w:t>Heading text</w:t>
  </w:r>
</w:p>
```

## Use case

* **Document structure** - Create logical hierarchy and navigation
* **Accessibility** - Screen readers use headings for navigation
* **SEO** - Search engines parse heading structure
* **Table of contents** - Auto-generate from heading levels

## Options

Configure the extension behavior:

**levels** `Array\<number\>` (default: \[1,2,3,4,5,6])

Supported heading levels

## Attributes

Node attributes that can be set and retrieved:

**level** `number` *required*

Heading level (1-6)

## Commands

### `setHeading`

Set a heading with specified level

> [!NOTE]
>
> Converts current block to heading

**Example:**

```javascript Usage theme={null}
editor.commands.setHeading({ level: 2 })
```

```javascript Full Example theme={null}
import { SuperDoc } from 'superdoc';
import 'superdoc/style.css';

const superdoc = new SuperDoc({
  selector: '#editor',
  document: yourFile,
  onReady: (superdoc) => {
    const editor = superdoc.activeEditor;
    editor.commands.setHeading({ level: 2 })
  },
});
```

**Parameters:**

**attributes** `HeadingAttributes` *required*

Heading attributes including level

### `toggleHeading`

Toggle between heading and paragraph

> [!NOTE]
>
> Switches between heading and paragraph for the same level

**Example:**

```javascript Usage theme={null}
editor.commands.toggleHeading({ level: 1 })
editor.commands.toggleHeading({ level: 3 })
```

```javascript Full Example theme={null}
import { SuperDoc } from 'superdoc';
import 'superdoc/style.css';

const superdoc = new SuperDoc({
  selector: '#editor',
  document: yourFile,
  onReady: (superdoc) => {
    const editor = superdoc.activeEditor;
    editor.commands.toggleHeading({ level: 1 })
    editor.commands.toggleHeading({ level: 3 })
  },
});
```

**Parameters:**

**attributes** `HeadingAttributes` *required*

Heading attributes including level

## Keyboard shortcuts

| Command | Shortcut | Description |
| - | - | - |
| toggleHeading() | `⌘/Ctrl-Alt-1` | Toggle heading level 1 |
| toggleHeading() | `⌘/Ctrl-Alt-2` | Toggle heading level 2 |
| toggleHeading() | `⌘/Ctrl-Alt-3` | Toggle heading level 3 |
| toggleHeading() | `⌘/Ctrl-Alt-4` | Toggle heading level 4 |
| toggleHeading() | `⌘/Ctrl-Alt-5` | Toggle heading level 5 |
| toggleHeading() | `⌘/Ctrl-Alt-6` | Toggle heading level 6 |

## Source code

[View on GitHub →](https://github.com/superdoc/docx-editor/tree/main/packages/super-editor/src/editors/v1/extensions/heading/heading.js)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.