Skip to content
GaudiGaudi Design System home

Search documentation

Search every page, heading and paragraph.

TableOfContents

Responsive article navigation with active sections, expandable heading branches, and an optional diagram and table index.

Post@gaudi/design-system/post/TableOfContentsView in StorybookSource

Reuses Scrollspy, Collapsible, Link and the shared expansion hook.

Installation

pnpm add github:ahmadassaf/design-system

Import from @gaudi/design-system. Load @gaudi/design-system/global.css once and add transpilePackages: ['@gaudi/design-system'] in Next.js.

import TableOfContents from '@gaudi/design-system/post/TableOfContents';

Usage

import TableOfContents from '@gaudi/design-system/post/TableOfContents';
<TableOfContents toc={toc} contentRef={articleRef} targetRef={readingViewportRef} offset={24} />

Examples

Playground

Storybook

Four or fewer sections

Storybook

API

8 props

Accessibility

Uses real links and marks the active heading with aria-current. Branch toggles have descriptive names and aria-expanded. Modified link clicks remain native; section navigation respects reduced motion and does not steal focus. Hidden branches keep their targets indexed and expand when a descendant becomes active.