Oddmash UI
All components

Table of Contents

Link to headings and track the visible section.

Usage

Supply heading IDs and an optional content ID or controlled active ID. Use native fragment links or handle navigation in the consumer.

Accessibility

Preserve section IDs, indicate the current location and allow mobile users to return focus to the disclosure or heading.

PropertyTypeDefault
headingsreadonly TocHeading[]Required
labelstringRequired
contentIdstringDocument body
offsetnumber0
activeIdstring | nullObserved
mobileLabelstringNone
onNavigatefunctionNative anchor
<>
  <TableOfContents label="On this page" mobileLabel="Browse sections"
    contentId="om-toc-demo-article"
    headings={[
      { id: 'om-toc-demo-setup', label: 'Installation', level: 2 },
      { id: 'om-toc-demo-usage', label: 'Usage guide', level: 3 }
    ]}
    onNavigate={(heading, event) => {
      event.preventDefault();
      document.getElementById(heading.id)?.scrollIntoView({ block: 'start' });
    }}
  />
  <article id="om-toc-demo-article">
    <h3 id="om-toc-demo-setup" tabIndex={-1}>Installation</h3>
    <p>Install the package.</p>
    <h3 id="om-toc-demo-usage" tabIndex={-1}>Usage guide</h3>
    <p>Learn how to use the library.</p>
  </article>
</>

Interactive documentation