2.0 alpha
These docs describe 2.0. Install it with @once-ui-system/core@alpha.
On 1.8.x? Read the 1.x docs
TrademarkTrademarkDocs
Ctrl k
Search docs...
Hooks

useHeadingLinks

Updated: February 22, 2026
View on GitHub
The useHeadingLinks hook extracts all heading elements (h2-h6) from the current page and returns them as a structured array. This is useful for creating table of contents, navigation menus, or document outlines. Used in components: HeadingNav
  • Automatically finds all headings on the page
  • Extracts heading text, ID, and level
  • Filters out headings with data-exclude-nav attribute
  • Generates IDs for headings without them
  • Updates on mount
Create a table of contents: Create a styled navigation menu: Exclude specific headings from navigation: Combine with scroll tracking to highlight active section:
  • Documentation sites: Auto-generate table of contents
  • Blog posts: Create article outlines
  • Long-form content: Improve navigation
  • Accessibility: Provide skip links
  • Only runs once on mount (not reactive to DOM changes)
  • Headings without IDs get auto-generated IDs
  • Only includes h2-h6 (h1 is typically the page title)
  • Respects data-exclude-nav attribute
Edit this page on GitHub
TrademarkTrademark
Built with curiosity by Lorant One and the Design Engineers Club