drupal/accordion-paragraph
By rang501@gmail.comMARKDOWNCreate an accessible accordion component implemented as a Drupal module using Drupal Single Directory Components (SDC). The component must meet WCAG 2.2 AA requirements and follow WAI-ARIA Authoring Practices for accordions. Styling must be done using Tailwind CSS utility classes only.
Implement the accordion as a Drupal module exposing one or more SDC components.
Each accordion is an SDC component with:
component.ymlComponent must be renderable via:
Component input data should be passed via SDC props (e.g. items, allow_multiple, expanded_by_default).
Accordion headers must be real <button> elements, not divs or links.
Each accordion item consists of:
Panels must be present in the DOM at all times (no conditional rendering that removes content).
Required relationships
Each header button:
Each panel:
Apply ARIA only where needed and correctly.
Header buttons
aria-expanded="true | false" reflects current statearia-controls="panel-id"Panels
role="region"aria-labelledby="header-id"hidden, inert, or equivalent to hide collapsed panels accessiblyDo not duplicate native semantics (e.g. no role="button" on <button>).
The accordion must be fully keyboard-operable:
Required
Tab / Shift+Tab: enter and exit accordion normallyEnter or Space: toggle the focused headerRecommended (ARIA pattern)
ArrowDown: move focus to next headerArrowUp: move focus to previous headerHome: move focus to first headerEnd: move focus to last headerFocus must remain on the header button when toggling.
Support:
State must stay in sync across:
aria-expandedUse Tailwind utility classes exclusively.
No inline styles.
Visual states must be distinguishable without color alone:
Focus styles must be clearly visible and meet contrast requirements.
Use Tailwind variants or state classes to reflect expanded state.
If transitions are used:
prefers-reduced-motionAnimations must never interfere with focus or announcements.
Attach JS using Drupal behaviors.
Must support:
No global state leakage.
Component must function without JS (all panels expanded by default).
Screen readers must announce:
Content inside expanded panels must be read in natural order.
Collapsed panels must not be reachable by screen readers.
Drupal module structure
SDC component files
Twig markup with proper semantics
Tailwind-based styling
Drupal behavior JS
Accessibility rationale explaining:
List of common accessibility pitfalls avoided