How to wire a chevron to a collapsible section
Answer in brief
Put the chevron inside a named button and synchronize aria-expanded with the visibility of the controlled content. The chevron can be decorative because the button supplies the state.
Open an invoice breakdown
Use “Tax details” as the button text and link aria-controls to the details region's unique id. Start collapsed, expand with Enter, then collapse again. Check that hidden line items disappear from keyboard navigation.
Recover focus when a section closes
If code can close the breakdown while a link inside it has focus, decide where focus should return. The disclosure button is a predictable destination when the user remains on the same invoice. Open the section, focus its final link, trigger the external close action and continue tabbing.
Sources
- [1] Disclosure (Show/Hide) Pattern | APG | WAI | W3C — W3C, accessed November 23, 2026
Frequently asked questions
Does aria-expanded hide the content automatically?
The application must change visibility. The attribute communicates the state to assistive technology.