Skip to content

Annotations

Important

Check out the official documentation on GitHub to learn more about writing and formatting syntax. Additionally, you can read the latest updates and features on Markdown by visiting the GitHub blog.

Flagship Features

One of the flagship features of Material for MkDocs is the ability to inject annotations – little markers that can be added almost anywhere in a document and expand a tooltip containing arbitrary Markdown on click or keyboard focus.

Configuration⚓︎

Configuration

This configuration allows to add annotations to all inline- and block-level elements, as well as code blocks, and nest annotations inside each other. Add the following lines to mkdocs.yml:

markdown_extensions:
  - attr_list
  - md_in_html
  - pymdownx.superfences

See additional configuration options:

Annotation Icons⚓︎

Annotation Icons

The annotation icon can be changed to any icon bundled with the theme, or even a custom icon, e.g. to material/arrow-right-circle. Simply add the following lines to mkdocs.yml:

theme:
  icon:
    annotation: material/arrow-right-circle # (1)!
  1. Enter a few keywords to find the perfect icon using our icon
    search
    and click on the shortcode to copy it to your clipboard:







    Some popular choices:

    • - material/plus-circle
    • - material/circle-medium
    • - material/record-circle
    • - material/arrow-right-circle
    • - material/arrow-right-circle-outline
    • - material/chevron-right-circle
    • - material/star-four-points-circle
    • - material/plus-circle-outline

    Usage⚓︎

    Using Annotations⚓︎

    Using Annotations

    Annotations consist of two parts: a marker, which can be placed anywhere in a block marked with the annotate class, and content located in a list below the block containing the marker:

    Text with annotations
    Lorem ipsum dolor sit amet, (1) consectetur adipiscing elit.
    { .annotate }
    
    1.  :man_raising_hand: I'm an annotation! I can contain `code`, __formatted 
        text__, images, ... basically anything that can be expressed in Markdown.
    

    Lorem ipsum dolor sit amet, (1) consectetur adipiscing elit.

    1. 🙋‍♂️ I'm an annotation! I can contain code, formatted
      text
      , images, ... basically anything that can be written in Markdown.

    Note

    Note that the annotate class must only be added to the outermost block. All nested elements can use the same list to define annotations, except when annotations are nested themselves.

    In Annotations⚓︎

    In Annotations

    When SuperFences is enabled, annotations can be nested inside annotations by adding the annotate class to the list item hosting the annotation content, repeating the process:

    Text with nested annotations
    Lorem ipsum dolor sit amet, (1) consectetur adipiscing elit.
    { .annotate }
    
    1.  :man_raising_hand: I'm an annotation! (1)
    { .annotate }
    
        1.  :woman_raising_hand: I'm an annotation as well!
    

    Lorem ipsum dolor sit amet, (1) consectetur adipiscing elit.

    1. 🙋‍♂️ I'm an annotation! (1)

      1. 🙋‍♀️ I'm an annotation as well!

    In Admonitions⚓︎

    In Admonitions

    The titles and bodies of admonitions can also host annotations by adding the annotate modifier after the type qualifier, which is similar to how inline blocks work:

    Admonition with annotations
    !!! note annotate "Annotations in admonitions titles. (1)"
    
       The titles and bodies, (2) of admonitions can also host annotations by adding the annotate modifier after the type qualifier, which is similar to how inline blocks work:
    
    1.  :man_raising_hand: I'm an annotation!
    2.  :woman_raising_hand: I'm an annotation as well!
    

    Annotations in admonition titles. (1)

    The titles and bodies, (2) of admonitions can also host annotations by adding the annotate modifier after the type qualifier, which is similar to how inline blocks work:

    1. 🙋‍♂️ I'm an annotation!
    2. 🙋‍♀️ I'm an annotation as well!

    In Content Tabs⚓︎

    In Content Tabs

    Content tabs can host annotations by adding the annotate class to the block of a dedicated content tab (and not to the container, which is not supported):

    Content tabs with annotations
    === "Tab 1"
    
        Lorem ipsum dolor sit amet, (1) consectetur adipiscing elit.
        { .annotate }
    
            1. :man_raising_hand: I'm an annotation!
    
    === "Tab 2"
    
        Phasellus posuere in sem ut cursus (1)
        { .annotate }
    
            1. :woman_raising_hand: I'm an annotation as well!
    

    Lorem ipsum dolor sit amet, (1) consectetur adipiscing elit.

    1. 🙋‍♂️ I'm an annotation!

    Phasellus posuere in sem ut cursus (1)

    1. 🙋‍♀️ I'm an annotation as well!

    In Everything Else⚓︎

    In Everything Else

    • The Attribute Lists extension is the key ingredient for adding annotations to most elements, but it has some limitations.
    • However, it's always possible to leverage the Markdown in HTML extension to wrap arbitrary elements with a div with the annotate class:
    HTML with annotations
    <div class="annotate" markdown>
    
    > Lorem ipsum dolor sit amet, (1) consectetur adipiscing elit.
    
    </div>
    
    1.  :man_raising_hand: I'm an annotation!
    

    Lorem ipsum dolor sit amet, (1) consectetur adipiscing elit.

    1. 🙋‍♂️ I'm an annotation!

    Known limitations

    Please note that annotations currently don't work in data tables as reported in #3453, as data tables are scrollable elements and positioning is very tricky to get right. This might be fixed in the future.