@imshaiksaif/webflow-custom-toc
v1.4.0
Published
A Table of Contents generator for Webflow
Downloads
13
Readme
Webflow Blog TOC
Library Usage
To use this library, follow the steps below:
Using with a CDN
Add the script to your HTML: Include the library script in the
<body>tag of your HTML file using a CDN:<script src="https://cdn.jsdelivr.net/npm/@imshaiksaif/webflow-custom-toc@latest/dist/index.js"></script>Prepare your HTML structure:
- Select the Richtext Element and give it the
ss-toc-content-compattribute:<div ss-toc-content-comp="toc1"> <!-- Your blog content with headings (e.g., <h2>, <h3>) --> </div> - Select the container for the Table of Contents (TOC) and give it the required data attributes:
<div ss-toc-comp="toc1" ss-option-heading-selector="h2, h3"></div>
- Select the Richtext Element and give it the
Initialize the TOC: The library will automatically generate the TOC for the container with the
ss-toc-compattributes. Ensure your headings (e.g.,<h2>,<h3>) are inside the blog content containerss-toc-content-comp.Customize options (optional): You can pass additional options to the script by adding
ss-option-*attributes to thess-toc-compcontainer. For example:<div ss-toc-comp="toc1" ss-option-heading-selector="h2, h3" ss-option-list-type="ul" ss-option-item-active-class="custom-active-class" ss-option-smooth-scroll="true" ss-option-scroll-speed="500"> </div>ss-option-heading-selector: Specify which headings to include (default:h1, h2, h3, h4, h5, h6).ss-option-list-type: Specify the list type (ul,ol, ornone).ss-option-item-active-class: Add a custom class to the active TOC item.ss-option-smooth-scroll: Enable smooth scrolling (default:false).ss-option-scroll-speed: Set the scroll speed in milliseconds (default:300).
Styling: Update custom styles in Webflow to the TOC container to match your website's design.
