Collapsible content¶
Use an expandable note for optional instructions, a longer explanation, or troubleshooting details.
Enable¶
pymdownx.details enables the collapsible ??? syntax; admonition also
enables regular !!! notes.
For non-collapsible notes with the same styling, see Admonitions.
Closed by default¶
Show the configuration advice
Keep one theme block in mkdocs.yml and merge new options into it.
??? note "Show the configuration advice"
Keep one `theme` block in `mkdocs.yml` and merge new options into it.
Open by default¶
Start with the defaults
Override only the settings your site needs.
The browser's native details element handles opening and closing, including
keyboard activation. It works without the theme's JavaScript.
Native HTML alternative¶
You can also write <details> directly. For Markdown inside the body, enable
md_in_html and add markdown:
Layout modes¶
Pixel Lab chooses each expanded body's layout automatically, like content tabs:
- A single code block or table fills the body flush.
- Prose, multiple blocks, and mixed content use a padded inset.
- Nested details and tabs select their layouts independently.
Flush content shares the details frame without a duplicate border or surrounding gap. Code retains its internal padding, and wide code and tables scroll horizontally inside the body.
A table without an extra inset
| Content | Layout |
|---|---|
| Single code block or table | Flush |
| Prose or mixed content | Padded |
Scoped layout overrides¶
Use .details-padded or .details-flush directly on a native <details>
element, or wrap selected ??? blocks using
Scope selected instances:
<div class="details-padded" markdown>
???+ note "Always padded"
```python
print("Keep an inset around this block")
```
</div>
For native HTML, place the class on the element:
<details class="details-flush" open>
<summary>Always flush</summary>
<pre><code>Keep code's internal padding.</code></pre>
</details>
Customization¶
Use the properties and selectors below to customize this component, following the Customization guide.
Component properties¶
These CSS variables take their default values from the corresponding theme settings.
| Property | Description | Theme setting | Default |
|---|---|---|---|
--highlight |
Summary background | highlight_color |
Golden yellow · #f5c842 |
--surface |
Expanded body background | surface_color |
Ivory · #fffdf2 |
--border |
Frame and summary divider | border_color |
Near-black · #101410 |
--shadow |
Frame's pixel shadow | shadow_color |
Near-black · #101410 |
Summary and body text inherit the page's text_color. Set color on details
to change it locally. All detail types share these styles.
See Colors for palette configuration and Fonts for typography defaults and overrides.
Component styles¶
Use these selectors to style the frame and summary. For the expanded content inset and flush presentation, see Layout modes.
| Selector | CSS properties | Description |
|---|---|---|
details |
background, border, box-shadow, margin, color |
The whole collapsible block, including its frame and inherited text color |
details > summary |
background, border-bottom, font-family, font-size, padding |
Summary fill, divider, typography, and inset |