An expand/collapse widget allows sections of content to be revealed or hidden, saving space and letting readers focus on what interests them most.
Native implementations like the HTML <details> element automatically handle keyboard and accessibility behaviors.
This custom version uses a button to toggle the visibility of an associated content region.
JavaScript updates both the aria-expanded state and the button label so screen readers and sighted users stay in sync.
aria-controls.hidden attribute when collapsed.