On This Page
Installation
Run the following command to install the Table of Contents component:
Usage
To use the Table of Contents component, import it into your project and pass the required props.
Popover Components
The TOC includes popover components for mobile/responsive views:
Advanced Usage
For more control over the TOC behavior, you can use the context providers:
Features
- Automatic scroll syncing with document sections
- Visual indicator for current section
- Responsive design with popover support
- RTL support
- Customizable styling
- Nested section support with indentation
- Smooth scrolling to sections
Custom Styling
You can customize the appearance using standard Tailwind classes:
Examples
Basic Example
On This Page
With Popover (Mobile-Friendly)
Props
TableOfContentsList
Prop | Type | Description |
---|---|---|
items | TOCItem[] | An array of items to display in the table of contents. |
isMenu | boolean | Optional. If true, styles the TOC as a menu. |
label | ReactNode | Optional. Adds a heading above the TOC items. |
TOCItem
Prop | Type | Description |
---|---|---|
title | React.ReactNode | The title of the section. |
url | string | The URL or anchor link to the section. |
depth | number | The depth level of the section in the document (1-4). |