Proposal: Collapse accessibility enhancements
#53.203 aberto em 18 de mar. de 2025
Métricas do repositório
- Stars
- (98.031 estrelas)
- Métricas de merge de PR
- (Mesclagem média 3d 4h) (248 fundiu PRs em 30d)
Description
What problem does this feature solve?
The collapse component does not comply with w3c accessibility guidelines here: https://www.w3.org/WAI/ARIA/apg/patterns/accordion/
What does the proposed API look like?
Proposed Changes:
-
Add an optional prop allowing user/consumer to set a heading level for the collapse button. We could use
headingLevel?: h1 | h2 | h3 | h4 | h5 | h6, and then wrap the collapse-button-header in the<h_>. -
Set an
aria-controlsattribute on each button, and the aria-controls would reference the id of the panel that the button controls. -
Add an optional Collapse prop,
panelsRole?: 'region' | 'none', by which consumers can optionally setrole="region"on the panels.
These changes would have little impact on consumers implementation, but would improve accessibility by default, and also give consumers powerful opt-in functionality to set the heading level and role="region".
Please let me know if you find the proposed changes acceptable.