Docusaurus v2 collapsible section in markdown

Viewed 2547
2 Answers

All you had to do was to add the gist code in your markdown file, I did the same and it worked out for me.

Check this out - HTML details tag

<details><summary>CLICK ME</summary>
<p>

#### yes, even hidden code blocks!

```python
print("hello world!")
```

</p>
</details>

As Germa pointed out, you can include HTML in Markdown, so using <details> and <summary> tags work. Also, since Docusaurus uses MDX, which allows React components in MDX, you can always write your own React components and embed them in your documents without needing support from Docusaurus for your use case.

Related