Headings
Headings establish document hierarchy from level 1 (H1) to level 6 (H6). They automatically populate the document outline panel, drive the generated Table of contents, and inherit section typography styles.
- Included in:
writingConfiguration,notesConfiguration,documentConfiguration - Pure-Dart import:
package:vyuh_document_elements/heading.dartorpackage:vyuh_document_elements/vyuh_document_elements.dart - Action namespace:
HeadingActions
Quick example
dart
import 'package:vyuh_document/vyuh_document.dart';
import 'package:vyuh_document_elements/vyuh_document_elements.dart';
final doc = Document.of(writingConfiguration, [
Heading('Quarterly Business Review', level: HeadingLevel.h1),
Heading('Revenue highlights', level: HeadingLevel.h2),
Paragraph('Arrived ahead of forecast across every region.'),
]);What you can configure
| Property | Type / Values | Purpose |
|---|---|---|
level | HeadingLevel (h1–h6, 1–6) | Semantic outline depth and default typography scale |
styleId | String? | Named paragraph style (for example Heading1–Heading6) controlling theme typography |
paragraphFormat | ParagraphFormat | Overrides alignment, spacing before/after, keepWithNext, borders, and indents |
children | List<DocumentInline> | Full inline runs, marks, links, inline fields, and footnotes |
Actions & commands
| Action ID | Effect |
|---|---|
HeadingActions.h1 … HeadingActions.h6 | Convert the active text block to heading level 1–6 (or toggle back to body paragraph) |
HeadingActions.level(int n) | Parameterized helper returning the action ID for level 1–6 |
Add heading shortcuts to a toolbar or bubble menu:
dart
final headingsGroup = ActionGroup(
id: 'headings',
actions: [
HeadingActions.h1,
HeadingActions.h2,
HeadingActions.h3,
],
);- Markdown input rules: Typing
#,##, …,######at the start of a paragraph converts it to the corresponding heading level automatically. - Canonical addressing: Query all headings in a document via
HeadingAddressfor custom navigation trees or anchor links.
Restricting usage
- Remove headings entirely: Start from
paragraphsConfiguration(rich text without headings) or call.withoutElements([Heading.element]). - Limit available heading levels in chrome: Include only
HeadingActions.h1–HeadingActions.h3in yourActionGroupand gateHeadingActions.h4–HeadingActions.h6inDocumentPolicyso authors stick to a clean 3-level hierarchy.
Format parity
| DOCX | HTML | Markdown | |
|---|---|---|---|
Native Heading1–Heading6 styles with <w:outlineLvl> | Shaped headings + PDF outline bookmarks | <h1>–<h6> | # through ###### ATX headings |