Skip to content

Docs: Add TableOfContents API reference page#33934

Merged
valentinpalkovic merged 5 commits into
nextfrom
copilot/update-table-of-contents-documentation
Mar 3, 2026
Merged

Docs: Add TableOfContents API reference page#33934
valentinpalkovic merged 5 commits into
nextfrom
copilot/update-table-of-contents-documentation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 25, 2026

TableOfContents has been available in @storybook/addon-docs since v7 but had no dedicated API documentation, leaving users confused about correct usage (particularly the common mistake of dropping <TableOfContents /> directly into MDX instead of using parameters.docs.toc).

Changes

  • New /docs/api/doc-blocks/doc-block-tableofcontents.mdx — Full API reference covering:

    • How TableOfContents is enabled (via parameters.docs.toc, not direct MDX placement)
    • All toc parameter options with types, defaults, and descriptions: contentsSelector, disable, headingSelector, ignoreSelector, title, unsafeTocbotOptions
    • Reuses existing code snippets (storybook-preview-enable-toc.md, storybook-preview-custom-toc.md, my-component-disable-toc.md)
    • Cross-references the Autodocs guide for step-by-step setup
  • /docs/writing-docs/doc-blocks.mdx — Added TableOfContents entry to the "Available blocks" section (alphabetically between Subtitle and Title), with the parameters.docs.toc namespace callout

  • Sidebar ordering — Bumped order numbers for Title (14→15), Typeset (15→16), Unstyled (16→17), useOf (17→18) to accommodate TableOfContents at position 14

Original prompt

This section details on the original issue you should resolve

<issue_title>[Documentation]: Description of usage details for TableOfContents in @storybook/addons-docs/blocks is missing (especially placement)</issue_title>
<issue_description>### Describe the problem

I've noticed that the official documentation for @storybook/addon-docs lacks information regarding the TableOfContents component, especially concerning its usage and placement options.

I understand that a dedicated Table of Contents addon was discontinued in Storybook v7+ because this functionality is now integrated into @storybook/addon-docs. However, I couldn't find any documentation explaining how to effectively use this built-in component.

When I add <TableOfContents title={"Content"} /> to an MDX file, it currently renders directly over the main content of the MDX file, pinned to the top. My goal is to position it on either the right or left side of the content area beside the MDX content, allowing it to remain visible and scrollable independently while the user scrolls through the MDX file. This would greatly enhance navigation and user experience for longer documentation pages.

Could you please provide guidance or update the documentation with details on:

  1. How to properly configure and use TableOfContents within MDX files.
  2. Available options for controlling its layout and positioning (e.g., to a sidebar, floating, etc.).

Many thanks!

Additional context

Storybook V10.2.3

import { Meta, TableOfContents } from "@storybook/addon-docs/blocks";

<TableOfContents title={"Content"} />

<Meta title="Getting started" />

# Heading 1
## Heading 1.1
## Heading 1.2
# Heading 2

```</issue_description>

<agent_instructions>Add documentation for TableOfContents to the documentation</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Summary by CodeRabbit

  • Documentation
    • Added comprehensive TableOfContents documentation explaining behavior, configuration options, and usage for docs (including global enablement and per-component toggles).
    • Added TableOfContents entry to the doc-blocks overview page.
    • Adjusted documentation sidebar ordering for several doc-block pages to reflect the new placement.

Co-authored-by: valentinpalkovic <5889929+valentinpalkovic@users.noreply.github.com>
Copilot AI changed the title [WIP] Update documentation for TableOfContents usage in Storybook docs: Add TableOfContents API reference page Feb 25, 2026
@valentinpalkovic valentinpalkovic changed the title docs: Add TableOfContents API reference page Docs: Add TableOfContents API reference page Feb 26, 2026
@valentinpalkovic valentinpalkovic marked this pull request as ready for review February 26, 2026 15:33
@valentinpalkovic valentinpalkovic added documentation ci:docs Run the CI jobs for documentation checks only. and removed ci:docs Run the CI jobs for documentation checks only. labels Feb 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 26, 2026

Fails
🚫 PR description is missing the mandatory "#### Manual testing" section. Please add it so that reviewers know how to manually test your changes.

Generated by 🚫 dangerJS against 78dfb58

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a20381d and 78dfb58.

📒 Files selected for processing (1)
  • docs/api/doc-blocks/doc-block-tableofcontents.mdx
✅ Files skipped from review due to trivial changes (1)
  • docs/api/doc-blocks/doc-block-tableofcontents.mdx

📝 Walkthrough

Walkthrough

Adds a new TableOfContents documentation page and a corresponding entry in the doc-blocks overview; updates sidebar ordering of several existing doc-block pages to accommodate the new entry.

Changes

Cohort / File(s) Summary
TableOfContents Documentation
docs/api/doc-blocks/doc-block-tableofcontents.mdx
New MDX doc added describing the TableOfContents doc block: fixed right-hand sidebar, hidden on small screens, configured via parameters.docs.toc, and documents options (contentsSelector, disable, headingSelector, ignoreSelector, title, unsafeTocbotOptions) with usage notes.
Doc Blocks Overview
docs/writing-docs/doc-blocks.mdx
Inserted a TableOfContents entry into the doc-blocks overview page with heading link, info callout about parameters.docs.toc, and descriptive text; placed after Subtitle and before Title sections.
Navigation Order Updates
docs/api/doc-blocks/doc-block-title.mdx, docs/api/doc-blocks/doc-block-typeset.mdx, docs/api/doc-blocks/doc-block-unstyled.mdx, docs/api/doc-blocks/doc-block-useof.mdx
Incremented sidebar order values to shift existing entries (Title: 14→15, Typeset: 15→16, Unstyled: 16→17, UseOf: 17→18) to accommodate the new TableOfContents entry.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@jonniebigodes jonniebigodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@valentinpalkovic thanks for addressing this and add the documentation 🙏 ! Left a couple of small items to be looked into.

Approving to unblock you

Comment thread docs/api/doc-blocks/doc-block-tableofcontents.mdx Outdated
Comment thread docs/api/doc-blocks/doc-block-tableofcontents.mdx Outdated
Comment thread docs/api/doc-blocks/doc-block-tableofcontents.mdx Outdated
valentinpalkovic and others added 3 commits February 27, 2026 14:15
Co-authored-by: jonniebigodes <joaocontadesenvolvimento@gmail.com>
Co-authored-by: jonniebigodes <joaocontadesenvolvimento@gmail.com>
Co-authored-by: jonniebigodes <joaocontadesenvolvimento@gmail.com>
@valentinpalkovic valentinpalkovic added the ci:docs Run the CI jobs for documentation checks only. label Feb 27, 2026
@valentinpalkovic valentinpalkovic merged commit fe92192 into next Mar 3, 2026
20 of 21 checks passed
@valentinpalkovic valentinpalkovic deleted the copilot/update-table-of-contents-documentation branch March 3, 2026 12:40
@github-actions github-actions Bot mentioned this pull request Mar 3, 2026
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:docs Run the CI jobs for documentation checks only. documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Documentation]: Description of usage details for TableOfContents in @storybook/addons-docs/blocks is missing (especially placement)

3 participants