← All Components
<mth-toc>
Table of contents navigation landmark that tracks active visible headings using ObserverPoolController.observeIntersection.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-toc>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/toc"></script>
<mth-toc></mth-toc>import '@methane-ui/ui/toc';
import '@methane-ui/react';
export function Example() {
return <mth-toc></mth-toc>;
}<script setup lang="ts">
import '@methane-ui/ui/toc';
</script>
<template>
<mth-toc></mth-toc>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/toc';
import { MthTocDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthTocDirective],
template: `<mth-toc></mth-toc>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/toc';
import MthToc from '@methane-ui/svelte/MthToc.svelte';
</script>
<MthToc></MthToc>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
label | label | string | "" | Accessible label for the <nav> landmark. |
heading | heading | string | "" | Visible section title above the list. |
activeId | active-id | string | "" | ID of the currently active heading highlighted with aria-current="location". |
targetSelector | target-selector | string | "" | Optional CSS selector to auto-discover headings with id attributes from the document. |
items | — | ReadonlyArray<unknown> | [] | Structured heading items when provided explicitly instead of targetSelector. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-select | { id: string; label: string; href: string } | Fired when a TOC link is activated. |
mth-active-change | { id: string } | Fired when intersection tracking or selection changes the active heading. |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| i18n | Routes 2 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |