Another way to do this is to use dash_html_components.Details
and dash_html_components.Summary
. This is native in HTML5, no callbacks required! See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details for details.
html.Details([
html.Summary('Label of the item'),
html.Div('Contents')
])
I use this in the dash user guide to hide/show the code blocks