Add tocbot to your gatsby site.
yarn add gatsby-plugin-tocbot
// gatsby-config.js
module.exports = {
plugins: [{
resolve: 'gatsby-plugin-tocbot',
options: {
tocbotOptions: {
contentSelector: '.js-toc',
collapseDepth: 5,
}
},
}]
}
Override thes css variables in your css.
/** default values */
:root {
--toc-cur-highlight-color: black;
--toc-text-color: inherit;
--toc-text-hover-color: #666;
}