Expandable container for progressive disclosure
Click the summary
See more examples
||Native element||Any, but should be a “summary, caption, or legend for the rest of the contents"|
||Boolean attribute||When present, the details are shown (everything after summary). When removed details are hidden. If you want Details open by default, add this attribute.|
Fires after Details was opened or closed. If
Is the content even necessary?
Although Details and Accordion are great tools for progressive disclosure, you should consider if the hidden content is necessary or if it could just be removed altogether.
Clickable elements inside summary
Some designs will include a button or other interactive element in
<summary> that should not toggle the details. Most elements behave as normal without toggling Details, but some, like in the example below, need an event handler to
preventDefault to stop this from happening:
See report history
The report history...
A common application of Details is an expandable navigation. Here's a working example:
aria-expanded attribute is managed automatically for you.