Skip to content

Collapsible Content

When creating documentation, there is some content that targets a small group of your users, but most users do not need it. This could be a longer description of a feature or task step, or it could be more technical detail only for administrators. Or maybe the extra content is only for users who meet a specific requirement, like using a proxy on their network. You could just include this extra content in the topic or maybe present it in an additional, optional topic.

With Material for MkDocs, you can use the Admonition feature and collapse the content so most of your users do not have to read it. If a user wants the extra content, they can click to expand the section and read it.

Note

This is a collapsed section that you expanded to read.

Using Collapsible Content

In Material for MkDocs, the collapsible section feature is associated with admonitions, like Note and Tip. For more information about supported admonition types, see the Material for MkDocs site.

  1. In the mkdocs.yml file, add the following information.

    markdown_extensions:
        - admonition
        - pymdownx.details
        - pymdownx.superfences
    
  2. In a topic, use an admonition, but start the block of text with ??? instead of !!!.

    ??? note
    
        This is a collapsed section that you expanded to read.