All Challenges

Accordion & FAQ Drawer

HTML/CSSEasyRazorpayCREDPaytm
30:00

Problem Brief

Create an accessible FAQ accordion supporting toggleable sections, aria-expanded sync, and an option for single-open vs multi-open mode.

Requirements

  • Render `.faq-item` elements each with a `.faq-trigger` button (`aria-expanded`) and `.faq-panel` content.
  • Clicking a closed `.faq-trigger` expands its panel (`hidden = false`, `aria-expanded="true"`).
  • In single-open mode (`[data-testid="single-mode"]` checked), opening one panel collapses previously open panels.
  • Clicking an already-open trigger collapses it (`aria-expanded="false"`, `hidden = true`).
Progressive Hints (2)
  • Loop over `.faq-item` rows when toggling in single-open mode to close non-clicked indices.
  • Keep `aria-expanded` and `panel.hidden` strictly in sync inside a single `render()` or helper.
Reference Solution

Stuck? Load the verified reference code into your editor.

Automated Test Suite

5 Test Cases Ready
  • All panels start collapsed with aria-expanded="false"Initial accordion state has zero expanded triggers
  • Clicking first trigger expands first panelSets aria-expanded="true" and unhides panel
  • Single-open mode closes first panel when second opensOnly one panel remains open while single-mode checkbox is checked
  • Unchecking single-open mode allows multiple open panelsMulti-open works when single-mode checkbox is unchecked
  • Clicking an open trigger collapses it cleanlyToggling open panel hides content and updates aria-expanded
solution.html
Live Sandboxed Previewiframe sandbox
Starter template loaded — add your <script> logic in the editor (or open Reference Solution) to make the widget interactive.