Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions docs/api/doc-blocks/doc-block-tableofcontents.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
title: 'TableOfContents'
sidebar:
order: 18
title: TableOfContents
---

The `TableOfContents` doc block displays an automatically generated list of links to other headings on the current page in the format of a table.

<Callout variant="info">
To use the storybook "sidebar" table of contents layout, it should be configured with `parameters.docs.toc`
</Callout>
Comment thread
txgh25 marked this conversation as resolved.

{/* prettier-ignore-start */}

```md title="TableOfContentsDocs.mdx"
import { Meta, TableOfContents } from '@storybook/addon-docs/blocks';

<Meta title="Docs/TableOfContents"/>

## Table of Contents

<TableOfContents title="Example Toc" headingSelector="h2,h3"/>

## Section 1

## Section 2

```

{/* prettier-ignore-end */}

### `TableOfContents`

```js
import { TableOfContents } from '@storybook/addon-docs/blocks';
```

TableOfContents accepts the following props:

### `title`

Type: `string | JSX.Element`

Determine the title to be displayed above the table of contents.


### `disable`

Type: `boolean`

When set to `true` prevents the rendering of the table.


### `headingSelector`

Type: `string`
Default: `h3`

CSS selector to determine which headings to include in the table of contents.

### `contentsSelector`

Type: `string`
Default: `.sbdocs-content`

CSS selector to determine the container that holds the content to be scanned for headings.

### `ignoreSelector`

Type: `string`
Default: `.docs-story *, .skip-toc`

CSS selector to determine which elements to ignore when scanning for headings.

### `className`

Type: `string`

Apply custom CSS classes to the table of contents' wrapping element.

### `unsafeTocbotOptions`

Type: `object`

Additional options to be passed directly to the underlying Tocbot.
Use as an escape hatch for features not yet supported by the TableOfContents component.

### `channel`

Type: `Channel`

Storybook's event channel to be used for navigation when clicking items in the table.
This is automatically injected so does not need to be set up manually.


10 changes: 10 additions & 0 deletions docs/writing-docs/doc-blocks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,16 @@ The `Subtitle` block can serve as a secondary heading for your docs entry.

![Screenshot of Subtitle block](../_assets/api/doc-block-title-subtitle-description.png)

### [TableOfContents](../api/doc-blocks/doc-block-tableofcontents.mdx)

<Callout variant="info">

Accepts parameters in the namespace `parameters.docs.toc`.

</Callout>
Comment thread
coderabbitai[bot] marked this conversation as resolved.

The `TableOfContents` block displays a list of the contents for the current docs page automatically formatted as a table.

### [Title](../api/doc-blocks/doc-block-title.mdx)

The `Title` block serves as the primary heading for your docs entry. It is typically used to provide the component or page name.
Expand Down
Loading