---
title: "Table of contents"
description: "The table of contents that follows the headings in view."
url: https://docscn.dev/docs/components/toc
lastModified: 2026-10-08T08:01:44.000Z
---

# Table of contents (/docs/components/toc)

> The table of contents that follows the headings in view.

## Installation [#installation]

```npm
npx shadcn@latest add @docscn/toc
```

## Usage [#usage]

[`DocsPage`](/docs/components/docs-page) shows the TOC beside the page on wide screens and as a popover on smaller ones. To use it elsewhere:

```tsx
import { TOCProvider, TOCScrollArea } from "@/components/docs/components/toc";
import { TOCItem, TOCItems } from "@/components/docs/components/toc/default";

<TOCProvider toc={toc}>
  <TOCScrollArea>
    <TOCItems>
      {toc.map((item) => (
        <TOCItem key={item.url} item={item} />
      ))}
    </TOCItems>
  </TOCScrollArea>
</TOCProvider>;
```

The active headings are highlighted with a thumb on a line that follows the heading levels. `useActiveAnchor`, `useActiveAnchors`, `useItems` and `useTOCItems` are re-exported from `components/toc`.

## Styles [#styles]

Pick a style for `DocsPage`'s TOC and TOC popover with `style`:

```tsx
<DocsPage
  toc={page.data.toc}
  tableOfContent={{ style: "clerk" }}
  tableOfContentPopover={{ style: "clerk" }}
>
  {/* ... */}
</DocsPage>
```

| Style              | Module                   | Looks like                                                                         |
| ------------------ | ------------------------ | ---------------------------------------------------------------------------------- |
| `normal` (default) | `components/toc/default` | A line that curves with the heading levels, and a thumb on the active headings.    |
| `clerk`            | `components/toc/clerk`   | A line that steps with the heading levels, highlighted beside the active headings. |
| `block`            | `components/toc/block`   | A highlight behind the active headings.                                            |

Each module exports `TOCItems`, `TOCItem` and `TOCEmpty`, so you can swap them in the example above.