Props
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | "Table of Contents" | TOC heading |
levels | number | 3 | Max heading level (1-6) |
showPageNumbers | boolean | true | Display page numbers |
hyperlinks | boolean | true | Make entries clickable |
className | string | — | Tailwind classes for title |
Basic usage
Custom title
Heading levels
Control how deep the TOC goes:Page numbers
Hyperlinks
Styling
Style the title:Full example
How it works
- Scans document for H1-H6 headings
- Filters by
levelsprop - Generates entries with indentation based on heading level
- Adds page numbers via Word’s PAGEREF field
- Creates hyperlinks to heading bookmarks
id props needed for TOC.
Updating the TOC
The TOC uses Word’s native field. To update page numbers after editing:- In Word: Right-click TOC → “Update Field”
- Or: Ctrl+A, then F9
