Skip to content

DaW888/toc-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Toc with React

Simple implement of TocBot. toc img

Quick config of tocbot:

import * as tocbot from 'tocbot';

useEffect(() => {
    tocbot.init({
        // Where to render the table of contents.
        tocSelector: '.js-toc',
        // Where to grab the headings to build the table of contents.
        contentSelector: 'main',
        // Which headings to grab inside of the contentSelector element.
        headingSelector: 'h1, h2, h3',
        // For headings inside relative or absolute positioned containers within content.
        hasInnerContainers: true,
        // Main class to add to lists.
        linkClass: 'toc-link',
        // Class that gets added when a list should be collapsed.
        isCollapsedClass: 'is-collapsed',
        // Smooth scrolling enabled.
        scrollSmooth: true,
        // Smooth scroll duration.
        scrollSmoothDuration: 420,
        headingsOffset: 40,
        collapseDepth: 0,
    });
}, [])

About

simple table of contents with react and tocbot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published