Mkdocs-material: Collapse table of contents and automatically expand active section

Created on 7 Feb 2018  路  3Comments  路  Source: squidfunk/mkdocs-material

When a single markdown file contains too many headers, like this one, the TOC is too long.

TIM鎴浘20180207234239.png

In this case, an auto-expand TOC may be more readable, like auto-expand TOC example, which uses hexo-theme-indigo.

enhancement

Most helpful comment

This is an enhancement and could be done with the collapsing logic of the navigation. It could be set via flag in the configuration. I may implement it in the future when I find the time.

All 3 comments

You can try with this CSS (it doesn't work exactly like your example, but it's close):

:not([data-md-state="blur"]) + nav {
  display: none;
}

This is an enhancement and could be done with the collapsing logic of the navigation. It could be set via flag in the configuration. I may implement it in the future when I find the time.

I'm closing this, as this will probably never get implemented. Material's default behavior should work pretty good, but it can also be extended by custom JavaScript. Giving users the option to auto-collapse the TOC is too specific to be useful. I want to allocate my time to stuff that needs to be fixed, not optional "nice" features. I'm sorry and hope you can understand.

Was this page helpful?
0 / 5 - 0 ratings