The HTML <details> element provides an accessible, keyboard-friendly expand/collapse interface out of the box. The <summary> element acts as the toggle, while any additional content inside is hidden until expanded.
This widget uses a button and a content region. The button updates its aria-expanded attribute, and the content region toggles using the hidden attribute. CSS transitions create a smooth animation.
Key accessibility considerations include:
aria-controls.aria-expanded to reflect visibility.