Skip to main content
Auto-generated table of contents from document headings.

Props

PropTypeDefaultDescription
titlestring"Table of Contents"TOC heading
levelsnumber3Max heading level (1-6)
showPageNumbersbooleantrueDisplay page numbers
hyperlinksbooleantrueMake entries clickable
classNamestringTailwind classes for title

Basic usage

Generates:

Custom title

No title:

Heading levels

Control how deep the TOC goes:

Page numbers



Styling

Style the title:

Full example


How it works

  1. Scans document for H1-H6 headings
  2. Filters by levels prop
  3. Generates entries with indentation based on heading level
  4. Adds page numbers via Word’s PAGEREF field
  5. Creates hyperlinks to heading bookmarks
Headings automatically get bookmark IDs. No manual 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