easy15 min

Build an Accordion

Build an accordion component where clicking a section header expands or collapses its content. Only one section should be open at a time. This tests your ability to manage state that controls which item is active.

useStateconditional renderinglists
  • Renders all section headers
  • No content is visible initially
  • Clicking a header opens its content
  • Clicking an open header closes it
  • Only one section is open at a time
Your Code
Loading editor...