---
title: "Header Block — Levels, Anchors, Shortcuts"
description: "Headings H1 to H6 with markdown shortcuts, anchor ids, and level conversion from the block settings menu."
source: https://blokeditor.com/docs/header/
lastmod: 2026-10-07
---

Framework JavaScript

Block Tools Header

# Header block: headings H1 to H6

Heading blocks from H1 to H6. It supports several toolbox entries, one per heading level, and keyboard shortcuts (# ## ### etc.).

Every level also has an optional toggle that collapses and expands its children. The toolbox lists "Toggle heading 1" through "Toggle heading 6", reachable with the markdown shortcuts `>#` through `>######`.

Converting an existing block into a toggle heading adopts its section: use "Turn into" or `blocks.convert` with `isToggleable: true`. Every following sibling becomes a child of the new toggle, up to the next heading of the same or higher rank. This matches Notion.

### Import

TypeScript

```
import { Header } from '@bloklabs/core/tools';
```

### Configuration

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `placeholder` | `string` | `level name (e.g. "Heading 2", localised)` | Placeholder text shown in an empty heading block. |
| `levels` | `number[]` | `[1,2,3,4,5,6]` | Restrict which heading levels are available. |
| `defaultLevel` | `number` | `2` | The heading level used when inserting a new header block. |
| `levelOverrides` | `Record<number, { tag?, name?, size?, marginTop?, marginBottom? }>` | `{}` | Per-level overrides for HTML tag, display name, or CSS values. |
| `shortcuts` | `Record<number, string>` | `undefined` | Custom markdown prefixes per heading level. If omitted, the default markdown prefixes (#, ## …) are used. Pass an empty object {} to disable the plain heading prefixes. The toggle-heading prefixes (`>#` … `>######`) are matched separately and are always active. You cannot configure or disable them here, and they still respect `levels`. |
| `anchorIds` | `boolean | (text: string, blockId: string) => string` | `undefined` | Opt-in text-derived anchor ids on rendered headings. true uses the built-in slugifier. It keeps Unicode letters/digits and letter case, strips punctuation and zero-width chars, and joins words with hyphens, e.g. «Обучайте команду» → id "Обучайте-команду". A function lets you generate ids yourself (empty string = no id). Ids stay in sync on text edits and survive level changes. A heading that carries its own data.anchor keeps that instead. Cross-block duplicate dedup is out of scope, so consumers dedup themselves. |

### Save Data

TypeScript

```
interface HeaderData {
  text: RichText;           // Heading text as segments (HeaderToolData holds HTML)
  level: number;            // 1–6
  isToggleable?: boolean;   // true when the heading has toggle (collapse/expand)
  textColor?: string;       // Block colour preset, present when set
  backgroundColor?: string; // Block background colour preset, present when set
  anchor?: string;          // Anchor id for in-document links, present when set
}
```

JSON

```
{
  "id": "def456",
  "type": "header",
  "data": {
    "text": [{ "text": "Getting Started" }],
    "level": 2
  }
}
```

### Usage Example

TypeScript

```
import { Blok } from '@bloklabs/core';
import { Header } from '@bloklabs/core/tools';

const editor = new Blok({
  holder: 'editor',
  tools: {
    header: {
      class: Header,
      levels: [1, 2, 3],
      defaultLevel: 2,
      placeholder: 'Enter a heading',
    },
  },
});
```
